public function download(){
$id = input('id');
$item = Db::name('imgsubmit')->where(['id'=>$id])->find();
Db::name('imgsubmit')->where(['id'=>$id])->update(['status'=>1]);
$tt = ltrim($item['zip'],'uploads/');
$path = config('upload_path').DS.$tt;
$arr = explode('/',$path);
$iname=$item['username'].'_'.$item['order_no'];
/*$filename = $arr[count($arr)-1];*/
$filename=$iname.'.zip';
//$file = fopen($path, "rb");
if (file_exists($path)) {
$filesize=filesize($path);
header('Content-Description:File Transfer');
header("Content-Type:application/octet-stream");
header('Content-Transfer-Encoding:binary');
header("Accept-Ranges: bytes");
header('Expires:0');
header('Cache-Control:must-revalidate');
header('Pragma:public');
header("Content-Length:".$filesize);
header("Content-Disposition:attachment;filename=".$filename);
//以下內(nèi)容是引用網(wǎng)友的代碼,由于原來的出處找不到了,在此表示萬分感謝和抱歉。
//打開文件
$fp = fopen($path, "rb");
//設(shè)置指針位置
ob_start();
fseek($fp,0);
//虛幻輸出
while (!feof($fp)) {
//設(shè)置文件最長執(zhí)行時(shí)間
set_time_limit(0);
print (fread($fp, 1024 * 8)); //輸出文件
flush(); //輸出緩沖
ob_flush();
}
fclose($fp);
exit ();}else{echo "文件不存在?。。?;die();}
}
文章標(biāo)題:PHP大文件下載(方式1不支持?jǐn)帱c(diǎn)續(xù)傳)
文章位置:
http://weahome.cn/article/jhepgs.html