plupload - 使用上传的文件发送另一个请求参数

发布于 2024-12-28 19:48:37 字数 297 浏览 4 评论 0原文

plupload文件对象。如何将此 id 发送到上传脚本? 上传脚本在 $_POST 中有 3 个变量 - 文件名、块编号和块总数。

如何向 plupload 的 POST 请求添加另一个参数(在我的例子中是 file.id)?

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)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

淡莣 2025-01-04 19:48:37

第一步是向 BeforeUpload 事件添加一个处理程序。

然后,如果您使用 multipart,您可以更改上传器设置以动态设置不同的 multipart 参数:(

plupload_instance.bind('BeforeUpload', function (up, file) {
    up.settings.multipart_params = {fileid: file.id}
});

警告:此示例覆盖所有 multipart_params,您可以通过设置 fileid 来更智能地播放它)

如果您不使用 multipart ,您唯一的选择是将参数作为标头传递,或者手动将参数添加到每个文件的 URL(这两个选项也应该在 BeforeUpload 中完成)。
请注意,当不使用 multipart 时,plupload 会将 namechunk 参数添加到 URL 您已为上传器设置的任何 URL 之后,例如每个文件,所以这就是额外参数所在的地方。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文