时间:2021-07-01 10:21:17 帮助过:14人阅读
$file_size = filesize($file_path);
header("Content-type: application/octet-stream;charset=gbk");
header("Accept-Ranges: bytes");
header("Accept-Length: $file_size");
header("Content-Disposition: attachment; filename=".$file_name);
$fp = fopen($file_path,"r");
$buffer_size = 1024;
$cur_pos = 0;
while(!feof($fp)&&$file_size-$cur_pos>$buffer_size)
{
$buffer = fread($fp,$buffer_size);
echo $buffer;
$cur_pos += $buffer_size;
}
$buffer = fread($fp,$file_size-$cur_pos);
echo $buffer;
fclose($fp);
return true;
}
http://www.bkjia.com/PHPjc/444963.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/444963.htmlTechArticlephp教程 文件下载实例代码 function xiazai($file_dir,$file_name) //参数说明: //file_dir:文件所在目录 //file_name:文件名 { $file_dir = chop($file_dir);//去掉路...