plupload - send another request parameter with uploaded file(plupload - 使用上传的文件发送另一个请求参数)
问题描述
plupload 在 文件对象.如何将此 id 发送到上传脚本?上传脚本在 $_POST
中有 3 个变量 - 文件名、块编号和块总数.
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.
如何在 plupload 的 POST 请求中添加另一个参数(在我的例子中是 file.id)?
推荐答案
第一步是为 BeforeUpload
事件添加一个处理程序.
The first step would be to add a handler to the BeforeUpload
event.
然后,如果您使用的是 multipart,您可以更改上传器设置以动态设置不同的 multipart 参数:
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}
});
(警告:这个例子覆盖了任何和所有的 multipart_params,你可以通过设置 fileid 玩得更聪明)
(warning: this example overrides any and all multipart_params, you can play it smarter than that by just setting fileid)
如果您不使用多部分,您唯一的选择是将参数作为标头传递,或者手动将参数添加到每个文件的 URL(这两个选项也应该在 BeforeUpload 中完成).请注意,当不使用 multipart 时,plupload 会将 name
和 chunk
参数添加到 URL after 您已经为上传器设置的任何 URL,例如每个文件,所以这是额外的参数所在.
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 - 使用上传的文件发送另一个请求参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:plupload - 使用上传的文件发送另一个请求参数


基础教程推荐
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- fetch 是否支持原生多文件上传? 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01