dongxu3029 2016-08-11 21:28
浏览 554
已采纳

如何显示进度和下载速度[关闭]

First, thanks to help me! How can i make a file first download to the browser and after that just popup the file... e.g http://mega.nz

I did server side script php, it sends to browser the file in chunks with the content-disposition header and it works!

But i want first download it to browser and show progress & speed.

English isn't my main language...

  • 写回答

2条回答 默认 最新

  • doujing1967 2016-08-11 21:48
    关注

    This is not going to be a complete answer, but I will try and get you started on the right path.

    First off, you'll need to use the a filesystem API to download your file to the browser cache. For chrome you can find more info here: https://developer.chrome.com/apps/fileSystem

    The API extends through HTML5 though, so you can do this in other browsers as well. See this article for more information: http://www.html5rocks.com/en/tutorials/offline/quota-research/#toc-desktop

    Now that is how it works behind the scenes, as far as implementing it yourself, take a look at FileSaver.js
    From their Github:

    FileSaver.js implements the saveAs() FileSaver interface in browsers that do not natively support it. There is a FileSaver.js demo that demonstrates saving various media types.

    FileSaver.js is the solution to saving files on the client-side, and is perfect for webapps that need to generate files, or for saving sensitive information that shouldn't be sent to an external server.

    This should allow you to target any modern browser for large file downloading, as well as pausing and resuming downloads.

    You may also want to look into NodeJS as there will likely be some packages made already you could leverage in your server application.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图