A support for the continuation of the breakpoint php file download class file, call method simple, class code concise, can remember the last download node, the implementation of the cumulative download, class name download, the class code is as follows:
functionDownload$path,$file) {$real=$path.‘ /‘.$file;if(!file_exists($real)) { return false;}$size=filesize($real);$size 2=$size-1;$range= 0;if(isset($_server[' Http_range '])) { Header(' http/1.1 206 Partial Content '); $range=Str_replace(' = ', '-',$_server[' Http_range ']); $range=Explode(‘-‘,$range); $range=Trim($range[1]); Header(' Content-length: '.$size); Header(' Content-range:bytes '.$range.‘ -‘.$size 2.‘ /‘.$size);} Else { Header(' Content-length: '.$size); Header(' Content-range:bytes 0-'.$size 2.‘ /‘.$size);}Header(' Accenpt-ranges:bytes ');Header(' Application/octet-stream ');Header("Cache-control:public");Header("Pragma:public");//solve the problem of Chinese garbled when downloading in IE$ua=$_server[' Http_user_agent '];if(Preg_match('/msie/',$ua)) { $ie _filename=Str_replace(' + ', '%20 ',UrlEncode($file)); Header(' Content-dispositon:attachment;filename= '.$ie _filename);} Else { Header(' Content-dispositon:attachment;filename= '.$file);}$fp=fopen($real, ' rb+ ');fseek($fp,$range); while(!feof($fp)) { Set_time_limit(0); Print(fread($fp, 1024)); Flush(); Ob_flush(); } fclose($fp);}/** * Parameter Description: * @param string $path: File path * @param string $file: file name * @return void*/
New Write PHP http Breakpoint continuation class file code