How to get a Plupload filename?

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-29 02:09:48

问题


I am using "plupload" to upload files then redirect to an acknowledgement page. What I would like to do is add the filename to the url string

EG(www.mysite/thanks.php?file=file.jpg)

For someone at my level the documentation for plupload comes across as somewhat sparse and I have been unable to identify which variable/object carries the file name.

Here's where I would like to put the code

Uploader.bind('FileUploaded', function(Up, File, Response) {
  if( (Uploader.total.uploaded + 1) == Uploader.files.length) {

    // var myfilename = !!!!!!!!!!!!!           

    window.location = 'uploaded.php?file=!!!!!!!!!';
    };
})

I would really appreciate some assistance with this, frankly it's driving me to distraction!


回答1:


This should do the trick:

Uploader.bind('FileUploaded', function(Up, File, Response) {
  if( (Uploader.total.uploaded + 1) == Uploader.files.length) {
    window.location = 'uploaded.php?file=' + encodeURIComponent(File.name);
  };
})

You can also check the documentation for additional options : http://www.plupload.com/plupload/docs/api/index.html#class_plupload.File.html




回答2:


I am not much sure about PHP but plupload use file as form variable for file you are trying to upload. If you just want to pass file name in url try different name may be filename instead of file.



来源:https://stackoverflow.com/questions/6956132/how-to-get-a-plupload-filename

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