Quantcast
Channel: Editor — DataTables forums
Viewing all articles
Browse latest Browse all 3744

upload to directorystructure

$
0
0

Please find below a part of the serverscript. I have read the File Upload section of the manual as well as the custom upload actions. My problem is that the file needs to be uploaded to the directory represented by ../uploads/archief01.rec_client/NAME where the value client07.NUMMER is the value of the first field of the editor. How do I reference to that value?

Field::inst( 'archief01.rec_client' )
                    ->validator( 'Validate::notEmpty' )
            ->options( Options::inst()
                ->table( 'client07' )
                ->value( 'NUMMER' )
                ->label( array('NAAM','client07.VOLET') )
                ->order( 'ZOEK asc' )
                ->where( function ($q) {
                    $q->where( 'client07.ISCLIENT', '1', '=' );
                    $q->where( 'client07.ARCHIEF', '0', '=' );
                    $q->where('client07.BLOKKEER','0','=');
                })
                ->render( function ( $row ) {
                    return $row['NUMMER'].' '.$row['NAAM'].' '.$row['client07.VOLET'];
                })
        ),
        Field::inst('archief01.image' )
    ->upload(
        Upload::inst( function ( $file, $id ) {
            move_uploaded_file( $file['tmp_name'], '/uploads/'.archief01.rec_client.'/'.$id );
            return $id;
        } )
            ->db( 'image', 'id', array(
                'fileName' => Upload::DB_FILE_NAME,
                'fileSize' => Upload::DB_FILE_SIZE
            ) )
    )
    ->setFormatter( 'Format::nullEmpty' );
}

$id is the primary key for the file.
Currently this gives a json error because reference to archief01.rec_client is not yet populated.
Thank you


Viewing all articles
Browse latest Browse all 3744