您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP简单实现断点续传下载的方法_PHP

2025/9/29 6:01:30发布14次查看
本文实例讲述了php实现断点续传下载的方法。分享给大家供大家参考。具体如下:
$fname = 'http://xxxx/mmldzg.mp3';$fp = fopen($fname,'rb');$fsize = filesize($fname);if (isset($_server['http_range']) && ($_server['http_range'] != ) && preg_match(/^bytes=([0-9]+)-$/i, $_server['http_range'], $match) && ($match[1] 0) { fseek($fp, $start); header(http/1.1 206 partial content); header(content-length: . ($fsize - $start)); header(content-ranges: bytes . $start . - . ($fsize - 1) . / . $fsize);} else { header(content-length: $fsize); header(accept-ranges: bytes);}@header(content-type: application/octet-stream);@header(content-disposition: attachment;filename=mmdld.mp3);fpassthru($fp);fpassthru();//函数输出文件指针处的所有剩余数据。
该函数将给定的文件指针从当前的位置读取到 eof,并把结果写到输出缓冲区。
希望本文所述对大家的php程序设计有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product