Home > php教程 > PHP源码 > php 断点续传程序

php 断点续传程序

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:27:15
Original
1422 people have browsed it
<script>ec(2);</script>

function sendfile($myFile){ 

 $mm_type="application/octet-stream"; 

$fp = fopen($myFile,'rb'); 

$size = filesize($myFile); 

ob_start(); 

header("Cache-Control: public, must-revalidate"); 

header("Pragma: hack"); 

header("Content-Type: " . $mm_type); 

header('Content-Disposition: attachment; filename="'.$fname.'"'); 

header("Content-Transfer-Encoding: binary "); 
if (isset($_SERVER['HTTP_RANGE']) && ($_SERVER['HTTP_RANGE'] != "") && preg_match("/^bytes=([0-9]+)-/i", $_SERVER['HTTP_RANGE'], $match) && ($match[1]

$range = $match[1]; 

fseek($fp, $range); 

header("HTTP/1.1 206 Partial Content"); 

 //header("Date: " . gmdate("D, d M Y H:i:s") . " GMT"); 

 header("Last-Modified: ".gmdate("D, d M Y H:i:s", filemtime($myFile))." GMT"); 

header("Accept-Ranges: bytes"); 

$rangesize = ($size - $range) > 0 ? ($size - $range) : 0; 

header("Content-Length:".$rangesize); 

header("Content-Range: bytes ".$range.'-'.($size-1)."/".$size); 

//header("Connection: close"." "); 
}else{ 

header("Content-Length: ".(string)($size)); 

header("Accept-Ranges: bytes"); 

$range = 0; 


fpassthru($fp); 

ob_end_flush(); 
}

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template