ajax 发布上传进度 - 仅限客户端

发布于 2024-12-26 03:47:25 字数 228 浏览 0 评论 0原文

我有一个表单,用户可以从中选择 100 个文件上传到我的服务器。

提交表单时,会向服务器发出一个可能长达数百 MB 的 POST 请求。我希望用户看到一个进度条来查看他们上传了多少。

我的问题如下:有没有办法只在客户端JS中实现这一点?我更愿意在不调用服务器上的 jsp 或 php 文件的情况下执行此操作。

我们可以使用 ext.js,但不能使用 jquery。

非常感谢,休

I have a form from which users can select 100s of files to upload to my server.

When submitting the form a post request is made to the server which may be 100s of MBs long. I would like the users see a progress bar to see how much they have uploaded.

My question is as follows: is there any way to achieve this in client side JS only? I would much prefer to do it without making a call to a jsp or php file on the server.

We can use ext.js but not jquery.

Many thanks, Hugh

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

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

发布评论

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

评论(1

留蓝 2025-01-02 03:47:25

不会。标准 HTML

上传不会向 JavaScript 公开其上传进度,因此上传进度脚本必须:

  1. 有某种方法从服务器检索上传状态,并检查定期
  2. 使用非标准方法提交上传,例如 Flash 或 Java 应用程序,或通过 JavaScript 分块上传。

某些浏览器(例如 Google Chrome)会不显眼地显示

上传(例如,在状态栏中),但很多人没有,而且我不知道如何从页面内检索该数据。

No. Standard HTML <form> uploads don't expose their upload progress to JavaScript, so upload progress scripts have to either:

  1. Have some way to retrieve the status of an upload from the server, and check that periodically
  2. Use a nonstandard method of submitting the upload, such as a Flash or Java application, or by chunking the upload in JavaScript

Some browsers (such as Google Chrome) will unobtrusively display the progress of a <form> upload (e.g, in the status bar), but many don't, and there's no way I'm aware of to retrieve that data from within the page.

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