Unknown upload field name submitted

Unknown upload field name submitted

SeppelchenSeppelchen Posts: 69Questions: 25Answers: 1
edited August 2015 in DataTables 1.10

If I select a file i can see: Unknown upload field name submitted

If I select a file i will upload i can see: Unknown upload field name submitted
on upload-many.php we had write:

<?php

/*
 * Example PHP implementation used for the index.html example
 */

// DataTables PHP library
include( "../php/DataTables.php" );

// Alias Editor classes so they are easy to use
use
    DataTables\Editor,
    DataTables\Editor\Field,
    DataTables\Editor\Format,
    DataTables\Editor\Mjoin,
    DataTables\Editor\Upload,
    DataTables\Editor\Validate;

// Build our Editor instance and process the data coming from _POST
Editor::inst( $db, 'datenpflege_lieferanten' )
    ->fields(
        Field::inst( 'liefnr' ),
        Field::inst( 'liefmc' ),
        Field::inst( 'ansprechpartner' )
    )
    ->join(
        Mjoin::inst( 'datenpflege_files' )
            ->link( 'datenpflege_lieferanten.id', 'datenpflege_filesuploaded.lieferanten_id' )
            ->link( 'datenpflege_files.id', 'datenpflege_filesuploaded.file_id' )
            ->fields(
                Field::inst( 'id' )
                    ->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/__ID__.__EXTN__' )
                        ->db( 'datenpflege_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'] >= 50000 ?
                                "Files must be smaller than 50K" :
                                null;
                        } )
                        ->allowedExtensions( [ 'png', 'jpg', 'pdf' ], "Please upload an image" )
                    )
            )
    )
    ->process( $_POST )
    ->json();

and on normal screen we had write:

var editor = new $.fn.dataTable.Editor( {
    ajax: "DataTables/ServerSide/upload-many.php",
    table: "#bilddatenbank",
    fields: [ {
            label: "Liefnr",
            name: "liefnr"
        }, {
            label: "Images:",
            name: "id",
            type: "uploadMany",
            display: function ( fileId, counter ) {
                return '<img src="'+table.file( 'files', fileId ).web_path+'"/>';
            },
            noImageText: 'No images'
        }
    ]
} );

Answers

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    edited August 2015

    name: "id",

    This uploads the files with the name "id", but your PHP is configured to expect them in an MJoin instance. So, as the example shows you would use the MJoin name as well - for example it would probably be datenpflege_files[].id in this case.

    Allan

  • SeppelchenSeppelchen Posts: 69Questions: 25Answers: 1

    Hello, now i had apply change:

    $(document).ready(function() {
        var editor = new $.fn.dataTable.Editor( {
            ajax: "DataTables/ServerSide/upload-many.php",
            table: "#bilddatenbank",
            fields: [ {
                    label: "Liefnr",
                    name: "liefnr"
                }, {
                    label: "Images:",
                    name: "datenpflege_files[].id",
                    type: "uploadMany",
                    display: function ( fileId, counter ) {
                        return '<img src="'+table.file( 'files', fileId ).web_path+'"/>';
                    },
                    noImageText: 'No images'
                }
            ]
        } );
     
        var table = $('#bilddatenbank').DataTable( {
            ajax: "DataTables/ServerSide/upload-many.php",
            columns: [
                { data: "liefnr" },
                { data: "liefmc" },
                { data: "ansprechpartner" },
                {
                    data: "datenpflege_files",
                    render: function ( d ) {
                        return d.length ?
                            d.length+' image(s)' :
                            'No image';
                    },
                    title: "Image"
                }
            ],
        } );
         var tableTools = new $.fn.dataTable.TableTools( table, {
        sRowSelect: "os",
        sRowSelector: 'td:first-child',
        aButtons: [
          { sExtends: "editor_create", editor: editor },
          { sExtends: "editor_edit",   editor: editor },
          { sExtends: "editor_remove", editor: editor }
        ]
      } );
      $( tableTools.fnContainer() ).appendTo( '#bilddatenbank_wrapper .col-sm-6:eq(0)' );
    } );
    
    <?php
    
    /*
     * Example PHP implementation used for the index.html example
     */
    
    // DataTables PHP library
    include( "../php/DataTables.php" );
    
    // Alias Editor classes so they are easy to use
    use
        DataTables\Editor,
        DataTables\Editor\Field,
        DataTables\Editor\Format,
        DataTables\Editor\Mjoin,
        DataTables\Editor\Upload,
        DataTables\Editor\Validate;
    
    // Build our Editor instance and process the data coming from _POST
    Editor::inst( $db, 'datenpflege_lieferanten' )
        ->fields(
            Field::inst( 'liefnr' ),
            Field::inst( 'liefmc' ),
            Field::inst( 'ansprechpartner' )
        )
        ->join(
            Mjoin::inst( 'datenpflege_files' )
                ->link( 'datenpflege_lieferanten.id', 'datenpflege_filesuploaded.lieferanten_id' )
                ->link( 'datenpflege_files.id', 'datenpflege_filesuploaded.file_id' )
                ->fields(
                    Field::inst( 'id' )
                        ->upload( Upload::inst( $_SERVER['DOCUMENT_ROOT'].'/upload/__ID__.__EXTN__' )
                            ->db( 'datenpflege_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'] >= 500000 ?
                                    "Files must be smaller than 50K" :
                                    null;
                            } )
                            ->allowedExtensions( [ 'png', 'jpg', 'pdf' ], "Please upload an image" )
                        )
                )
        )
        ->process( $_POST )
        ->json();
    
    

    But if i try upload I can't see that it will upload i can't see any error but i can't also see any image who is uploaded...:'(

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    Have you checked your server's error log? If not, that is the first thing I would suggest doing.

    Also, I would suggest checking your browser's console for any errors. If there are no errors there, inspect the Ajax request that the upload triggers and find out what the server is returning.

    Allan

  • SeppelchenSeppelchen Posts: 69Questions: 25Answers: 1
    edited August 2015

    Hello, I had fix the path to upload folder now. But now I get this error:

    TypeError: f.files[a] is undefined
    http://***/DataTables/js/dataTables.editor.min.js
    Line 54

    I can't see any image but i can see table: datenpflege_files
    get some entrys and table datenpflege_filesuploaded get also some entrys.

    But than i can not re open this row if i try open i can see same error
    TypeError: f.files[a] is undefined
    http://***/DataTables/js/dataTables.editor.min.js
    Line 54

    And is there any possibility to display a loader while files are upload. That would be better for all.

    Hope you can help on both cases.

  • SeppelchenSeppelchen Posts: 69Questions: 25Answers: 1

    Hello could anybody help? How we can fix that?

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    Hi,

    table.file( 'files', fileId ).web_path

    The first parameter passed into file() should be the table name where the file information is. You are passing in files, but the table name is actually datenpflege_files. I would suggest fixing that.

    I was going to login to the URLs you sent me by e-mail (thanks for them). However I get:

    Die Domain "..." ist nicht verfügbar.

    Just to let you know in case that doesn't fix the issue.

    Thanks,
    Allan

  • SeppelchenSeppelchen Posts: 69Questions: 25Answers: 1

    Hello Allan,
    beautiful it helps. Now regarding my last question from previous post:

    And is there any possibility to display a loader while files are upload. That would be better for all.

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    This should actually happen already. If the browser supports it (and not all do) a percentage upload complete will be shown. It is typically only shown briefly since the upload will normally happen quickly.

    Allan

  • SeppelchenSeppelchen Posts: 69Questions: 25Answers: 1

    Hello, where it should display?
    I cant see any proccess bar on upload form

This discussion has been closed.