Image upload but file id won't add in another table as foreign key

Image upload but file id won't add in another table as foreign key

bassam2008bassam2008 Posts: 2Questions: 1Answers: 0
Editor::inst( $db, 'tb_news' , 'news_id')
    ->fields
    (
        Field::inst( 'news_id' ),
        Field::inst( 'news_title' ),
        Field::inst( 'news_text' ),
        Field::inst( 'news_date' ),
        Field::inst( 'image' )
            ->setFormatter( 'Format::ifEmpty', null )
            ->upload
            (    Upload::inst( $_SERVER['DOCUMENT_ROOT'] . '/datatable-demo-server-side-in-phpmysql-and-ajax' . '/upload/__ID__.__EXTN__' )
                ->db
                ( 'files', 'id', array
                    (
                        'filename'    => Upload::DB_FILE_NAME,
                        'filesize'    => Upload::DB_FILE_SIZE,
                        'web_path'    => Upload::DB_WEB_PATH,
                        'system_path' => Upload::DB_SYSTEM_PATH
                    )
                )
                ->validator
                ( 
                    function ( $file ) 
                    {
                        return$file['size'] >= 5242880 ?
                            "Files must be smaller than 5M" :
                            null;
                    } 
                )
                ->allowedExtensions( [ 'png', 'jpg', 'gif' ], "Please upload an image" )
            )
    )
    ->process( $_POST )
    ->json();

this what I used to upload and insert
sorry for my bad English

Answers

  • bassam2008bassam2008 Posts: 2Questions: 1Answers: 0
    <br />
    <b>Warning</b>:  call_user_func() expects parameter 1 to be a valid callback, class 'DataTables\Editor\Format' does not have a method 'ifEmpty' in <b>C:\Program Files (x86)\Ampps\www\datatable-demo-server-side-in-phpmysql-and-ajax\php\Editor\Field.php</b> on line <b>775</b><br />
    {"data":[{"DT_RowId":"row_25","news_id":"25","news_title":"lll","news_text":"llllll","news_date":"0000-00-00","image":null}]}
    
  • allanallan Posts: 63,205Questions: 1Answers: 10,415 Site admin

    Hi,

    Format::ifEmpty requires the Editor 1.5.4 package which was released yesterday. Are you using the 1.5.4 version of the PHP libraries for Editor?

    Allan

This discussion has been closed.