summaryrefslogtreecommitdiffstats
path: root/system/helpers/download_helper.php
diff options
context:
space:
mode:
authorGeorge Petculescu <gxgpet@gmail.com>2016-09-28 23:01:59 +0200
committerGeorge Petculescu <gxgpet@gmail.com>2016-09-28 23:01:59 +0200
commite36664c07896a9a9ef69daad5dc9f880ea08e5c4 (patch)
tree195127fc93ccc2b8795933a36e4a9bae7968ac8b /system/helpers/download_helper.php
parentf394b9e0a764d47532363cae8f3e491718fcf8fa (diff)
- download helper uses better file buffering when the content of a local file is output'd
Diffstat (limited to 'system/helpers/download_helper.php')
-rw-r--r--system/helpers/download_helper.php16
1 files changed, 5 insertions, 11 deletions
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index a6463dfd7..3701e0b8b 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -121,11 +121,6 @@ if ( ! function_exists('force_download'))
$filename = implode('.', $x);
}
- if ($data === NULL && ($fp = @fopen($filepath, 'rb')) === FALSE)
- {
- return;
- }
-
// Clean output buffer
if (ob_get_level() !== 0 && @ob_end_clean() === FALSE)
{
@@ -146,13 +141,12 @@ if ( ! function_exists('force_download'))
exit($data);
}
- // Flush 1MB chunks of data
- while ( ! feof($fp) && ($data = fread($fp, 1048576)) !== FALSE)
- {
- echo $data;
- }
+ // Flush the file
+ if (@readfile($filepath) === FALSE)
+ {
+ return;
+ }
- fclose($fp);
exit;
}
}