jQuery file upload doesn't submit extra parameters

John Livermore picture John Livermore · Mar 26, 2013 · Viewed 19.6k times · Source

I need to use the formData parameter available in the jQuery File Upload control to send additional data to the server on submit. The default implementation for formData is to invoke a function that grabs all controls in the form and serializes them to an array (using the jQuery serializeArray() method).

I have controls in my form, but when the file is uploaded, I am not getting any additional data. When I inspect via Fiddler, there is nothing in the request that shows these form fields are being submitted.

Is there something additional that needs to be done to get these to submit?

Btw, these two links discuss formData...

https://github.com/blueimp/jQuery-File-Upload/wiki/Submit-files-asynchronously https://github.com/blueimp/jQuery-File-Upload/wiki/Options ...for this one search the page for formData.

For what its worth, the multipart option is set to true.

Answer

Yasser Shaikh picture Yasser Shaikh · Nov 5, 2013

I also needed to pass an extra parameter and here is what i used :

$('#fileupload').fileupload({
    formData: {
                    param1: 'test'
                    ,param2: "value2"
                    ,param3: "yasseshaikh"
              }
});

The formData option can be used to set additional form data programmatically.