I'm trying to use the blueimp jQuery File Upload in my project. It suits my needs fairly well but I need to change the url files are uploaded to dynamically after the plugin is created and configured. I've done a good deal of investigation, but, unfortunately, found nothing useful. In general, I have a button to choose files and fileupload action covering the actual upload. The basic creation looks like this:
$('[upload-button]').fileupload(new FileUploadConfig())
And configuration itself:
function FileUploadConfig() { // is set to a unique value for each file upload this.url = 'temporary'; this.fileInput = $('[upload-button]'); //... some other code }
The thing I need to do is change the url in this config and then call data.submit()
. I've found out, that this configuration is saved using $.data()
and tried to solve the problem with such code
// get the current fileupload configuration var config = $.data($('[upload-button]').get(0), 'fileupload'); // change the url configuration option config.options.url = file.link; //send a file data.submit();
However, this does not work the way I wanted.
Any ideas on how to accomplish this?
Just capturing this here for posterity.
In the current jQuery-upload rev, override the add(evt,data) function and set the url property of the the data object:
fileupload({ add: function(e, data) { data.url = 'customURL' ... }, ... }
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