Upload Function - A server error occurred while uploading the file

Upload Function - A server error occurred while uploading the file

akp982akp982 Posts: 2Questions: 1Answers: 0
edited February 13 in Editor

While trying to use the upload function for images with DataTables 1.8 I'm getting the below PHP error which I can't seem to work out the cause off.

Has anyone seen this before / got any thoughts on how to fix?

[13-Feb-2019 05:01:56 Europe/Dublin] PHP Fatal error: Uncaught Error: Function name must be a string in C:\inetpub\CommsScreens\Admin\php\lib\Editor\Upload.php:382
Stack trace:

exec(Object(DataTables\Editor))">exec(Object(DataTables\Editor))">0 C:\inetpub\CommsScreens\Admin\php\lib\Editor\Editor.php(1218): DataTables\Editor\Upload->exec(Object(DataTables\Editor))

_upload(Array)">_upload(Array)">1 C:\inetpub\CommsScreens\Admin\php\lib\Editor\Editor.php(863): DataTables\Editor->_upload(Array)

_process(Array)">_process(Array)">2 C:\inetpub\CommsScreens\Admin\php\lib\Editor\Editor.php(661): DataTables\Editor->_process(Array)

process(Array)">process(Array)">3 C:\inetpub\CommsScreens\Admin\php\table.edit.php(36): DataTables\Editor->process(Array)

4 {main}

thrown in C:\inetpub\CommsScreens\Admin\php\lib\Editor\Upload.php on line 382

JS

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'Cards', 'CardID' )
    ->fields(
        Field::inst( 'format' ),
        Field::inst( 'title' ),
        Field::inst( 'body' ),
        Field::inst( 'image' )
            //->setFormatter( Format::ifEmpty( null ) )
            ->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/__ID__.__EXTN__' )
                ->db( 'files', 'CardID', array(
                    'filename'    => Upload::DB_FILE_NAME,
                    'filesize'    => Upload::DB_FILE_SIZE,
                    'web_path'    => Upload::DB_WEB_PATH,
                    'system_path' => Upload::DB_SYSTEM_PATH
                ) )
                ->validator( Validate::fileSize( 500000, 'Files must be smaller that 500K' ) )
                ->validator( Validate::fileExtensions( array( 'png', 'jpg', 'jpeg', 'gif' ), "Please upload an image" ) )
            )
    )
    ->process( $_POST )
    ->json();

Answers

  • akp982akp982 Posts: 2Questions: 1Answers: 0

    It's to do with my validator statements. I've managed to turn them comment them out and move onto the next issue for now

  • colincolin Posts: 3,657Questions: 0Answers: 645

    Hi @akp982 ,

    That looks OK with the validator statements. The only thing I can think of is whether you didn't include the full list of use so Validate is unknown. Take a look at the "Server Script" tab on this page here - it would be worth comparing to your script.

    Hope that does the trick,

    Cheers,

    Colin

Sign In or Register to comment.