From 826b6196b748c2c1ccca0dbb5703fd50c600afa5 Mon Sep 17 00:00:00 2001 From: George Petculescu Date: Fri, 30 Sep 2016 21:34:44 +0300 Subject: - download helper uses better file buffering when the content of a local file is output'd --- system/helpers/download_helper.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'system') diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index a6463dfd7..7f5c2397a 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) + // Flush the file + if (@readfile($filepath) === FALSE) { - echo $data; + return; } - fclose($fp); exit; } } -- cgit v1.2.3-24-g4f1b