I am trying to send custom POST variables with each uploaded file.
I have it set up so that each file has 2 fields where users can enter tags and a description for that file.
The code I am using is
uploader.bind('UploadFile', function (up, file) {
$.extend(up.settings.multipart_params, {
'tags': $('#tags_' + file.id).val(),
'description': $('#description_' + file.id).val()
});
});
The above code seems to work for every file except the first.
Is this the proper way to send custom post data for individual files?
UploadFile
is a callback that is triggered after a file is uploaded, so you are actually setting the params of the current file for the next file.
You need to use the BeforeUpload
callback to achieve what you are trying to do, this callback is executed just before any request is sent to the server, this even allows you to dynamically change the URL to where you want to upload your file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With