我可以使用 jQuery UI 进度条来指示下载文件的进度吗?

发布于 2024-08-28 05:07:49 字数 193 浏览 5 评论 0原文

我有一个网页,其中有多个文件可供下载。这些文件的大小从 1MB 到 40MB 不等。为了帮助用户了解文件下载过程中实际发生的情况,我想添加一个进度条,以直观方式显示下载进度。

jQuery UI 进度条适合这种任务吗?如果是这样,是否有一些我可以遵循的此类编码示例? (是的,我已经查看了 jQuery UI 网站上的相关内容)。

谢谢。

I have a web page that has several files available for download. These files vary in size from 1MB to 40MB. To help the user see that something is actually happening during the file download process, I would like to include a progress bar that gives a visual indication of the download progress.

Would the jQuery UI Progress Bar work for this kind of task? If so, are there some examples of such coding that I could follow? (Yes, I have reviewed the jQuery UI site on this).

Thanks.

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

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

发布评论

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

评论(3

虚拟世界 2024-09-04 05:07:49

简而言之,不,你不能这样做。

列出这些文件供下载的页面与下载开始后的事务无关。由浏览器显示进度条并指示下载何时完成。一旦用户下载文件,他们的浏览器和网络服务器之间就会发生对话 - 您的页面不再涉及。

In short, no, you can't do this.

The page listing these files for download has nothing to do with the transaction after the download has begun. It's up to the browser to display a progress bar and indicate when the download has completed. Once the user is downloading a file, the dialog takes place between their browser and the webserver - your page is no longer involved.

黎夕旧梦 2024-09-04 05:07:49

如果我没记错的话,所有浏览器都内置了进度栏。
所以你不需要制作一个。

If I'm not mistaken, all browsers have built in progress bar.
So you don't need to make one.

冷默言语 2024-09-04 05:07:49

嗯,问题有点相反:
你需要的是一些东西来表明你的 php 正在将文件的内容读入某个东西(很可能是一个标头)。当标头/字符串完成后,浏览器下载或多或少会接管。

这至少是我在 PHP 和文件下载方面的经验。

我有一个理论,您可以使用 PHP 找出已读取的数据量,以及与文件总大小相比的数据量,然后使用某种 AJAX 技术进行显示。
再次强调:这只是一个理论。它没有经过测试。但我现在也面临着同样的挑战。我的任务是首先从 FTP 服务器读取文件,然后将其推送到浏览器。

Well, the problem is a bit the other way around:
What you need is something to show that you php is reading the content of the file into something (most likely a header thing). When the header/string is done, the browser download more or less takes over.

That's at least my experience with PHP and file downloading.

I have a theory that you could with PHP find out how much data has been read, and how much this is compared with the total size of the file, then show that using some AJAX technique.
Again: this is just a theory. It is not tested. But I am having the same challenge my self at the moment. My task is that the file is first read from a FTP-server, then pushed to the browser.

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