Can I use jQuery UI Progress Bar to indicate the p

2019-01-20 15:37发布

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.

4条回答
我命由我不由天
2楼-- · 2019-01-20 15:55

Yes, if you change such as your code: http://www.dave-bond.com/blog/2010/01/JQuery-ajax-progress-HMTL5/

Browser support: CanIuse

查看更多
Animai°情兽
3楼-- · 2019-01-20 15:55

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.

查看更多
干净又极端
4楼-- · 2019-01-20 15:56

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

查看更多
Deceive 欺骗
5楼-- · 2019-01-20 16:13

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.

查看更多
登录 后发表回答