plupload - 发送另一个请求参数与上传的文件 [英] plupload - send another request parameter with uploaded file
问题描述
plupload 在文件对象。这个ID如何被发送到上传脚本?
上传脚本在 $ _ POST
中包含3个变量 - 文件名,块数和块的总数。
如何添加另一个参数到plupload的POST请求(在我的情况下,file.id)?
第一步是将一个处理程序添加到 BeforeUpload
事件中。然后,if您可以更改上传器设置来动态设置不同的多部分参数:$ p $
plupload_instance.bind('BeforeUpload',函数(up,file){
up.settings.multipart_params = {fileid:file.id}
});
(警告:这个例子覆盖了任何和所有的multipart_params,只要设置如果你不使用multipart,你唯一的选择是将参数作为头部传递,或者手动将param参数添加到每个文件的URL(这两个选项也应该在BeforeUpload中完成)。
请注意,不使用multipart时,plupload会将名称
和 chunk
params添加到URL 之后,你已经为上传器设置了任何URL,对于每个文件,所以这是额外的参数。
plupload creates nice ids in file object. How this id can be sent to the upload script?
The upload script has 3 variables in $_POST
- file name, chunk number and total number of chunks.
How to add another parameter to plupload's POST request (in my case, the file.id)?
The first step would be to add a handler to the BeforeUpload
event.
Then, if you are using multipart, you can change the uploader settings to dynamically set different multipart params:
plupload_instance.bind('BeforeUpload', function (up, file) {
up.settings.multipart_params = {fileid: file.id}
});
(warning: this example overrides any and all multipart_params, you can play it smarter than that by just setting fileid)
if you are not using multipart, your only options would be to pass the argument as a header, or to manually add the param to the URL for each file (these 2 options should also be done within BeforeUpload).
Note that when not using multipart, plupload will add the name
and chunk
params to the URL after any URL you already set for the uploader, for each file, so this is where extra params go.
这篇关于plupload - 发送另一个请求参数与上传的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!