View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0010135 | mantisbt | bugtracker | public | 2009-02-15 16:40 | 2009-10-07 14:20 |
Reporter | olegos | Assigned To | vboctor | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | fixed | ||
Product Version | 1.2.0a2 | ||||
Fixed in Version | 1.2.0rc2 | ||||
Summary | 0010135: Downloading large attachments results in Internal Server Error - 500 | ||||
Description | I can upload large (several MB) attachments ok ($g_file_upload_method=DISK, and I can see the files appear in the storage directory), but attempts to download them result in Server Error 500. Turns out that the problem is with readfile() php function in file_download.php. The note "TimB 11-Feb-2008 10:23" at http://us.php.net/readfile provides the solution: "To anyone that's had problems with Readfile() reading large files into memory the problem is not Readfile() itself, it's because you have output buffering on. Just turn off output buffering immediately before the call to Readfile(). Use something like ob_end_flush()." My phpinfo() shows that output_buffering is "no value" (probably the default). I added ob_end_flush() in file_download.php in the "flush output buffer to protect download" section, and it fixed the problem for me. | ||||
Tags | patch | ||||
Attached Files | bug10135.patch (304 bytes)
--- file_download.php.orig 2009-02-15 16:24:25.656250000 -0600 +++ file_download.php 2009-02-15 16:25:05.187500000 -0600 @@ -89,6 +89,7 @@ if ( ob_get_length() ) { @ob_end_clean(); } + ob_end_flush(); # Make sure that IE can download the attachments under https. header( 'Pragma: public' ); | ||||
Also, other notes at http://us.php.net/readfile give more good ideas w.r.t. readfile(). Maybe there should be a call to set_time_limit(0) to not run into the max_execution_time limit, or read large files in chunks. By the way, I propose a new category "attachments" in this tracker. |
|
Patch against git trunk is attached. |
|
MantisBT: master 03f6cb7d 2009-07-04 13:40 Details Diff |
Fixes 0010135: Downloading large attachments results in Internal Server Error - 500. |
Affected Issues 0010135 |
|
mod - file_download.php | Diff File | ||
MantisBT: master-1.2.x bc945ed9 2009-07-04 13:40 Details Diff |
Fixes 0010135: Downloading large attachments results in Internal Server Error - 500. |
Affected Issues 0010135 |
|
mod - file_download.php | Diff File |