I'm integrating dropzone.js into my form, but I have an issue regarding my file uploads. I have my dropzone set up, and file uploads are in the $_FILES array. I want to call file_save_upload to handle the file management, but per the code:

// Make sure there's an upload to process.
if (empty($_FILES['files']['name'][$form_field_name])) {
    return NULL;

it looks for the files under $_FILES['files']['name']. The dropzone.js uploads my files to $_FILES['file']['file'].

I haven't seen an easy way to specify an input element for dropzone.js to upload to. On the Form API side, I could just mimic the functionality of file_save_upload(), but all the code already exists and it does a lot, and I'd hate to duplicate it.

Maybe I can copy the $_FILES['file']['file'] array over to $_FILES['files'], then call file_save_upload()? I'm trying to make sure there is a better way to do it before I start hacking.


1 Answer 1


I now have the files under $_FILES['files'].

My JS code:

(function ($) {

    Drupal.behaviors.dz = {
        attach: function (context, settings) {
            Dropzone.options.picsForm = {
                paramName: "files",
                autoProcessQueue: false,
                uploadMultiple: true,
                parallelUploads: 100,
                maxFiles: 100,

                init: function() {
                    var dz = this;
                    // #edit-next is the id of my submit button
                    this.element.querySelector("#edit-next").addEventListener("click", function(e) {




The '$form_field_name' parameter is a numeric index now, so I just get the count of the $_FILES['names'] array and call file_save_upload() for each one.

  • 4
    Is it possible that you share your final implementation?
    – duru
    Aug 27, 2015 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.