Unable to pass additional parameters in plupload

匿名 (未验证) 提交于 2019-12-03 02:24:01

问题:

I'm using plupload, the JQuery UI implementation. I'm trying to pass additional parameters to the server, but I can't make it work. It should be pretty straightforward, the parameters are already set when the function is executed, so that should not be a problem. I've tried this:

I've also tried to add this in the $('form').submit section:

uploader.bind('BeforeUpload', function(up)     {     up.settings.multipart_params =     {         'ordre': ordreibruk,         'mode': m     };  }); 

But to no avail.

I'm sure I'm overlooking something really simple, but what?

Kind regards, Anders

回答1:

I must confess I use to put my parameters as query string parameters in the url :

  • during init : url: '/upload.aspx?id='+Id,
  • or later : upldr.settings.url = upldr.settings.url + '&token=' + myToken;

It works fine. Hope this will help



回答2:

Had the same issue. Stumbled upon this snippet that can easily translated into coffescript as well that works for my project. Allows you to pass multipart params after initialization (like in the case a field can change before the upload is hit)

var myUploader = $('#uploader').plupload('getUploader'); myUploader.bind('BeforeUpload', function(up, file) {     up.settings.multipart_params = {path : $("#path").val()}; }); 

Call it after you do your normal initialize and setup of $("#divOpplaster").plupload(...) (and set your ID appropriately to your uploader field, of course)



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!