简体   繁体   中英

How to dynamically change Plupload url

I have setup Plupload to send to a PHP script checking for a parameter "gal" like:

$("#uploader").plupload({
  url : 'upload.php?gal='+$('#gallery').val()
});

This retrieves the value from a drop down, but it grabs the value of the drop down when initialized. I need to change this every time the drop down is changed. I tried:

$("#gallery").change(function() {
  $('#uploader').data("uiPlupload").options.url = 'upload.php?gal='+$(this).val();
});

This is changes the url for this value, however I guess this isn't the correct parameter as even though I can see in Firebug that this changes, it still uses the initialized value.

I have also tried:

$("#uploader").bind('BeforeUpload', function(up, file) {
  up.settings.url = 'upload.php?gal='+$("#gallery").val();
});

This doesn't get triggered at all.

Can someone shed some light on how I would change this?

Thanks.

Figured it out. You have to get the uploader instance and then set in the settings like:

$("#gallery").change(function() {
    var up = $('#uploader').plupload('getUploader');
    up.settings.url = 'upload.php?gal='+$(this).val()
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM