<delect id="sj01t"></delect>
  1. <em id="sj01t"><label id="sj01t"></label></em>
  2. <div id="sj01t"></div>
    1. <em id="sj01t"></em>

            <div id="sj01t"></div>
            php語言

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

            時間:2025-01-20 11:32:31 php語言 我要投稿
            • 相關推薦

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

              項目遇見了一個錯誤。下載報表時數據量太大,文件達到了300多M,這時出現了“頁面未找到”的錯誤,開始以為是服務器文件不存在,后來看了下確實有的,然后嘗試了多次,發現小文件是可以下載的。于是確定是文件太大的原因。以下是小編為大家搜索整理的php readfile下載大文件失敗的解決方法,希望能給大家帶來幫助!更多精彩內容請及時關注我們應屆畢業生考試網!

              具體如下:

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

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

              ?

            1
            2
            3
            4
            5
            6
            7
            8
            9
            10
            11
            12
            13
            14
            15
            16
            17
            18
            19
            20
            21
            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 "

            Content error

            The file does not exist!

            ";

              PHP實現遠程下載文件到本地

              PHP文件下載類

              php做下載文件的實現代碼及文件名中亂碼解決方法

              php使瀏覽器直接下載pdf文件的方法

              php實現的支持斷點續傳的文件下載類

              php中強制下載文件的代碼(解決了IE下中文文件名亂碼問題)b

            【php readfile下載大文件失敗的解決方法】相關文章:

            PHP中讀取大文件的方法04-08

            PHP實現大文件上傳源代碼05-03

            PHP快速讀取大文件的例子02-08

            PHP中讀取大文件實現方法04-02

            PHP中讀取大文件實現方法詳解04-30

            php環境上傳大文件需要注意哪些問題08-04

            php使用file-get-contents讀取大文件的方法07-12

            php下載代碼怎么寫07-13

            PHP解決session死鎖的解決方法01-26

            <delect id="sj01t"></delect>
            1. <em id="sj01t"><label id="sj01t"></label></em>
            2. <div id="sj01t"></div>
              1. <em id="sj01t"></em>

                      <div id="sj01t"></div>
                      黄色视频在线观看