blueimp/jQuery-File-Upload — Issue #745: Submit additional Form Data
Author: sanoi96
Created: 2011-11-02 10:17:01+00:00
State: open

Hi

Since quite a long time i try to submit additional Form Data for each individual file upload. I just want 3 new form fields where i can put a date, a time and a name. Those three together should be the new file name.

It sounds easy and the wiki entry is very well written but it really won't work for me. I'm new to "ajax" and a noob in javascript.

So what i did was this:

I put these things in the application.js:
// Initialize the jQuery File Upload widget:

$('#fileupload').fileupload({
formData: {example: 'test'}
});

$('#fileupload').bind('fileuploadsubmit', function (e, data) {
var inputs = data.context.find(':input');
if (inputs.filter('[required][value=""]').first().focus().length) {
return false;
}
data.formData = inputs.serializeArray();
});

And this is my index.html:

Title:
{{if name}}${name}{{else}}Untitled{{/if}}
${sizef}

And I put this in the upload.php file:

$name = $_REQUEST['title[]'];

I know this is just for one part of the name but if one works the other ones will be easy for me ;)

Thanks