国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

php readfile下載大文件失敗的解決方法

2024-05-04 23:57:25
字體:
來源:轉載
供稿:網友

本文實例講述了php readfile下載大文件失敗的解決方法。分享給大家供大家參考,具體如下:

大文件有200多M,只下載了200K就提示下載完成,且不報錯。

原因是PHP內存有限制,需要改為按塊下載,就是把大文件切塊后逐塊下載

if (file_exists($file)){  if (FALSE!== ($handler = fopen($file, 'r')))  {    header('Content-Description: File Transfer');    header('Content-Type: application/octet-stream');    header('Content-Disposition: attachment; filename='.basename($file));    header('Content-Transfer-Encoding: chunked'); //changed to chunked    header('Expires: 0');    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');    header('Pragma: public');    //header('Content-Length: ' . filesize($file)); //Remove    //Send the content in chunks    while(false !== ($chunk = fread($handler,4096)))    {      echo $chunk;    }  }  exit;}echo "<h1>Content error</h1><p>The file does not exist!</p>";

希望本文所述對大家PHP程序設計有所幫助。


注:相關教程知識閱讀請移步到PHP教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 兰州市| 彰化市| 泌阳县| 怀仁县| 尉氏县| 汾阳市| 黄梅县| 沂南县| 庄浪县| 平乡县| 鹤庆县| 湖南省| 静乐县| 苏尼特右旗| 平塘县| 崇信县| 屏边| 马尔康县| 麻阳| 雷山县| 延长县| 柳州市| 玉田县| 登封市| 高雄市| 正阳县| 邢台县| 康保县| 苍南县| 华坪县| 辽宁省| 正镶白旗| 台东县| 新和县| 东丽区| 青龙| 竹溪县| 平顺县| 思南县| 泰安市| 邵武市|