PHP实现的支持断点续传的下载类

发布时间:2019-08-07 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了PHP实现的支持断点续传的下载类脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

转自:http://www.jb51.net/article/55523.htm
断点续传测试方法:

使用linux wget命令去测试下载, wget -c -O file http://xxx

1.先关闭断点续传
$flag = $obj->download($file, $name);

test@ubuntu:~/Downloads$ wget -O test.zip http://demo.test.com/demo.php
--2013-06-30 16:52:44-- http://demo.test.com/demo.php
正在解析主机 demo.test.com... 127.0.0.1
正在连接 demo.test.com|127.0.0.1|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 10445120 (10.0M) [application/octet-stream]
正在保存至: “test.zip”

30% [=========>                                 ]3,146,580  515K/s 估时 14s
^C
test@ubuntu:~/Downloads$ wget -c -O test.zip http://demo.test.com/demo.php
--2013-06-30 16:52:57-- http://demo.test.com/demo.php
正在解析主机 demo.test.com... 127.0.0.1
正在连接 demo.test.com|127.0.0.1|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 10445120 (10.0M) [application/octet-stream]
正在保存至: “test.zip”
30% [=========>                                 ]3,146,580  515K/s 估时 14s
^C 

可以看到,wget -c不能断点续传

2.开启断点续传

$flag = $obj->download($file, $name, true);
test@ubuntu:~/Downloads$ wget -O test.zip http://demo.test.com/demo.php

--2013-06-30 16:53:19-- http://demo.test.com/demo.php
正在解析主机 demo.test.com... 127.0.0.1
正在连接 demo.test.com|127.0.0.1|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度: 10445120 (10.0M) [application/octet-stream]
正在保存至: “test.zip”

20% [=====> ] 2,097,720 516K/s 估时 16s
^C
test@ubuntu:~/Downloads$ wget -c -O test.zip http://demo.test.com/demo.php
--2013-06-30 16:53:31-- http://demo.test.com/demo.php
正在解析主机 demo.test.com... 127.0.0.1
正在连接 demo.test.com|127.0.0.1|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 206 Partial Content
长度: 10445121 (10.0M),7822971 (7.5M) 字节剩余 [application/octet-stream]
正在保存至: “test.zip”

100%[++++++++++++++++++++++++=========================================================================>] 10,445,121 543K/s 花时 14s

2013-06-30 16:53:45 (543 KB/s) - 已保存 “test.zip” [10445121/10445121])

脚本宝典总结

以上是脚本宝典为你收集整理的PHP实现的支持断点续传的下载类全部内容,希望文章能够帮你解决PHP实现的支持断点续传的下载类所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。