1. A Change of Season
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Mar 2004
    Next Door
    Rep Power

    How to get Dropzone.js to update input values and post?

    Hi I use Dropzone.js to drag files for upload.

    It's almost there ( Here is the fiddle ).

    When I post, on the next page php print_r($_POST) doesn't have any value for input "file".

    Here is what I get from printr($_FILES)
    PHP Code:
    Array ( [file] => Array ( [name] => [type] => [tmp_name] => [error] => [size] => ) ) 
    What am I doing wrong?

    Last edited by English Breakfast Tea; August 2nd, 2017 at 07:13 AM.
  2. #2
  3. Wiser? Not exactly.
    Devshed God 2nd Plane (6000 - 6499 posts)

    Join Date
    May 2001
    Bonita Springs, FL
    Rep Power
    You shouldn't have your file input (or it should be in a class="fallback" element). Dropzone.js will immediately upload the files to your server once they are dropped, then it appends the response to the form.

    So what you'd have on the server side is something like
    if (isset($_FILES['file'])){
        $data = SaveUploadSomewhere($_FILES['file']);
        echo '<input type="checkbox" value="'.$data['id'].'" name="files[]"> '.htmlspecialchars($data['name']);
    Basically you accept the uploaded file, generate a reference to it then return that reference as an input to be added to the form.

    Then when you post the final form you gather those references and link up the files as needed.
    Recycle your old CD's

    If I helped you out, show some love with some reputation, or tip with Bitcoins to 1N645HfYf63UbcvxajLKiSKpYHAq2Zxud

IMN logo majestic logo threadwatch logo seochat tools logo