[GH-ISSUE #259] download large file issues #187

Closed
opened 2026-03-02 15:56:36 +03:00 by kerem · 2 comments
Owner

Originally created by @kewlfft on GitHub (Nov 30, 2019).
Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/259

readfile() on large files can create issues even if in theory the documentation says it can handle any size. I personally had issues for files over 4GB. This is made worse if several users download the file at the same time. It seems the simplest way to handle this is to output the file in “chunks”.
I have implemented the solution proposed here and it worked for me.
To see whether replacing:

        readfile($path . '/' . $dl);

with:

        set_time_limit(0);
        $file = @fopen($path . '/' . $dl,"rb");
        while(!feof($file))
        {
            print(@fread($file, 1024*8));
            ob_flush();
            flush();
        }

was something we could implement.

Originally created by @kewlfft on GitHub (Nov 30, 2019). Original GitHub issue: https://github.com/prasathmani/tinyfilemanager/issues/259 `readfile()` on large files can create issues even if in theory the documentation says it can handle any size. I personally had issues for files over 4GB. This is made worse if several users download the file at the same time. It seems the simplest way to handle this is to output the file in “chunks”. I have implemented the solution proposed [here](https://www.media-division.com/the-right-way-to-handle-file-downloads-in-php/) and it worked for me. To see whether replacing: ~~~ readfile($path . '/' . $dl); ~~~ with: ~~~ set_time_limit(0); $file = @fopen($path . '/' . $dl,"rb"); while(!feof($file)) { print(@fread($file, 1024*8)); ob_flush(); flush(); } ~~~ was something we could implement.
kerem 2026-03-02 15:56:36 +03:00
Author
Owner

@EV-soft commented on GitHub (Nov 30, 2019):

Missing:
@fclose($file);

<!-- gh-comment-id:560000367 --> @EV-soft commented on GitHub (Nov 30, 2019): Missing: `@fclose($file);`
Author
Owner

@kewlfft commented on GitHub (Nov 30, 2019):

@EV-soft good point, thanks

<!-- gh-comment-id:560002400 --> @kewlfft commented on GitHub (Nov 30, 2019): @EV-soft good point, thanks
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tinyfilemanager#187
No description provided.