时间:2021-07-01 10:21:17 帮助过:189人阅读
$file_path='test.pdf';$file_name='test.pdf';$fp=fopen($file_path,"r");$file_size=filesize($file_path);header("Content-type:application/octet-stream");header("Accept-Ranges:bytes");header("Accept-Length:$file_size");header("Content-Disposition:attachment;filename=".$file_name);$buffer=1024;$file_count=0;while(!feof($fp) && ($file_size-$file_count>0)){ $file_data=fread($fp,$buffer); $file_count+=$buffer; echo $file_data;}fclose($fp);
多谢 jam00 ,这个折腾了我好几天