我目前正在研究一种在页面上显示文件下载状态的方法。
我知道这是不需要的,因为用户通常在浏览器中具有下载状态,但我想让用户保持在他正在下载的页面上,只要下载是持久的。为此,下载状态应与文件实际状态匹配(而不是假进度条)。也许它还会显示用户下载的速度,并根据当前的下载速率估计所需的时间。
这可以使用 PHP 和 Javascript 来完成吗?或者它真的需要 Flash 或 Java 吗?
服务器上的某个地方不应该有关于谁正在以什么速度和多少下载什么的信息吗?
提前感谢您的帮助。
I'm currently looking into a way of showing the file download status on a page.
I know this isnt needed since the user usually has a download status in the browser, but I would like to keep the user on the page he is downloading from, as long as the download is lasting. To do that, the download status should match the status the file actually has (not a fake prograss bar). Maybe it will also display the speed the user is downloading at, and estimate the time it will take, depending on the current download rate.
Can this be done using PHP and Javascript? Or does it realy require Flash or Java?
Should not somewhere on the Server be an information about who is downloading what at what speed and how much?
Thank you for your help in advance.
发布评论
评论(2)
不太可能跨浏览器,但请查看 http://markmail.org/message/kmrpk7w3h56tidxs#query:jquery%20ajax%20download%20progress+page:1+mid:kmrpk7w3h56tidxs+state:results 进行了相当密切的努力。 IE(一如既往)是不玩球的罪魁祸首。
Not really possible cross-browser, but have a look into http://markmail.org/message/kmrpk7w3h56tidxs#query:jquery%20ajax%20download%20progress+page:1+mid:kmrpk7w3h56tidxs+state:results for a pretty close effort. IE (as usual) is the main culprit for not playing ball.
您可以使用两个单独的 php 文件来完成此操作,第一个文件用于下载过程。
就像这样:
第二个文件将用于通过 Ajax 持续读取 yourtempFile.txt 。由于开始打印,因此不会使用会话和 Cookie。
You can do it with two seperate php files, first file for downloading process.
Like as:
Second file would be used for reading yourtempFile.txt by Ajax continusly. Using Sessions and Cookies wouldn't be used because of starting print.