Plupload 上传 +同步形式问题

发布于 2024-10-21 13:59:44 字数 725 浏览 1 评论 0原文

我有一个传统表单的设置,使用 jQuery 工具验证器 检查并通过 POST 提交。我喜欢这个类不需要额外的类名或其他多余的元数据来验证,标准 HTML5 属性就足够了。

我现在想使用 Plupload 上传解决方案扩展此功能。我知道现在所有现代上传解决方案都通过 Ajax 工作,因此我正在考虑一种设置,其中用户填写表单,将文件放入上传队列,然后提交表单。表单提交意味着:

  1. 通过 jQuery Tools Validator 进行验证...
  2. 如果验证通过,则上传上传队列中的所有文件...(到临时文件夹)
  3. 如果上传顺利,则通过 POST 实际提交表单并从临时文件夹中移动文件文件夹到永久位置。

我在 Uploadify 中进行了类似的设置,成功上传后,文件名会附加到隐藏的输入字段中。提交表单后,我通过 $_POST 获得了所有文件名。然而,jQuery Tools Validator 和 Uploadify 之间存在冲突。这就是我现在研究 Plupload 的原因。

我的问题?

  1. 您觉得这个设置怎么样?这是一个好的策略吗?
  2. 我将如何在技术层面上实现这一点?

谢谢。

I have a setup with a traditional form that's checked with jQuery Tools validator and submitted via POST. I like that this class does not require extra classnames or other superfluous metadata to validate, standard HTML5 attributes are enough.

I now would like to extend this functionality with the Plupload upload solution. I know that all modern upload solutions work via Ajax these days, so I was thinking about a setup in which the user fills out the form, puts files in the upload queue and then submits the form. The form submit would imply:

  1. Validation through jQuery Tools Validator...
  2. If validated, uploading all files in the upload queue... (to a temporary folder)
  3. If upload went well, actual submit of the form via POST and moving files from temporary folder to permanent location.

I had a similar setup in place with Uploadify, where the filenames where appended into a hidden input field after succesful upload. On submit of the form, I thus had all filenames via $_POST. However, there were conflicts between jQuery Tools Validator and Uploadify. That's why I'm now looking into Plupload.

My questions?

  1. What do you think of this setup? Is this a good strategy?
  2. How would I go about implementing this on a technical level?

Thanks.

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

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

发布评论

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

评论(1

冰雪梦之恋 2024-10-28 13:59:44

我已经找到答案了。 Plupload 内置了这个非常好的功能。它被设计为适合现有的表单。它使用 AJAX 上传文件,但会在同步发布表单之前返回上传结果。这样,在发布使用 Plupload 丰富的表单时,您还可以在 POST 变量中获得上传的结果。

文档中并不清楚,但是在您提交示例中的示例表单后,它指出:

“上传与您可能习惯的有点不同,文件被上传到临时文件夹,然后当表单提交后,您将获得将文件移动到正确位置所需的所有信息。这种设计方式是为了更轻松地将其应用到现有表单中,低级核心 API 支持这两种方法。”

非常好的上传解决方案。到处都有一些小问题,但我确信 PEBKAC

I've found the answer. Plupload has this very nice functionality built in. It is designed to fit into an existing form. It uses AJAX to upload the files, but it returns the results of the upload before posting the form synchronously. This way, on posting a form enriched with Plupload, you also have the result of the upload in your POST variables.

It isn't really clear in the documentation, but after you submit a sample form from the examples, it states:

"Uploading is a bit different than you might be used to, files are uploaded to the temp folder, then when the form is submitted you get all the info you need to move around the files to the correct location. It's designed this way to make it easier to just apply it to an existing form. The low level core API has support for both methods."

Very nice upload solution. Some minor issues here and there, but I'm sure PEBKAC

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