Error on File Upload

Error on File Upload

davykiashdavykiash Posts: 35Questions: 13Answers: 1

Hello,

Am using the file upload functionality of the editor for the first time. I get an error when I choose a file to upload

The following error is captured in the upload script library:

Undefined index: upload LINE::382 || FILE:: .....\datatables\Editor\Upload.php

I have managed to do the set up as follows:

Frontend

//File Upload
editor_upload = new $.fn.dataTable.Editor( {
    "ajax": {
            "url": "../actions/process.php",
            "type": "POST",
            "data": function ( d ) {
                 return $.extend( {}, d, {
                   "mpl_srv": "178",
                 } );
              },
          },
    table: "#upload_table",
    fields: [                           
                {
                    label: "File Name:",
                    name: "assets_save_name"
                },
                {
                    label: "Image:",
                    name: "assets_image",
                    type: "upload",
                    display: function ( file_id ) {
                        return '<img src="'+editor_upload.file( 'files', file_id ).web_path+'"/>';
                    },
                    clearText: "Clear",
                    noImageText: 'No image'
                }
        ]
    });

Server End

json_decode(Editor::inst( $db_details, $table, 'uuid')
    ->fields(


        Field::inst( 'assets_link_record_uuid' ),                       
        Field::inst( 'assets_save_name' ),

        
        Field::inst( 'assets_image' )
            ->setFormatter( 'Format::ifEmpty', null )
            ->upload( Upload::inst( 'D:/web/file.uploads'.'/test/__ID__.__EXTN__' )
                ->db( $table , 'uuid', array(
                    'assets_file_name'    => Upload::DB_FILE_NAME,
                    'assets_file_size'    => Upload::DB_FILE_SIZE,
                    'assets_web_path'    => Upload::DB_WEB_PATH,
                    'assets_system_path' => Upload::DB_SYSTEM_PATH
                ) )
                ->validator( function ( $file ) {
                    return $file['size'] >= 500000 ?
                        "Files must be smaller than 500K" :
                        null;
                } )
                ->allowedExtensions( array( 'png', 'jpg', 'gif' ), "Please upload an image" )
            ),          
        
        )

Please assist.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin
    Answer ✓

    Hi,

    Can you show me the "Headers" section from your browser's Network inspector when uploading the file. Specific the data that is being sent to the server.

    Thanks,
    Allan

  • davykiashdavykiash Posts: 35Questions: 13Answers: 1

    @allan You pointed me to the right direction and I sorted it out. Thanks!

This discussion has been closed.