diff options
Diffstat (limited to 'system/helpers/download_helper.php')
-rw-r--r-- | system/helpers/download_helper.php | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 19192a147..5efbc4930 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -37,21 +37,21 @@ // ------------------------------------------------------------------------ -/** - * Force Download - * - * Generates headers that force a download to happen - * - * @param string filename - * @param mixed the data to be downloaded - * @param bool wether to try and send the actual file MIME type - * @return void - */ if ( ! function_exists('force_download')) { + /** + * Force Download + * + * Generates headers that force a download to happen + * + * @param string filename + * @param mixed the data to be downloaded + * @param bool wether to try and send the actual file MIME type + * @return void + */ function force_download($filename = '', $data = '', $set_mime = FALSE) { - if ($filename == '' OR $data == '') + if ($filename === '' OR $data === '') { return FALSE; } @@ -73,14 +73,7 @@ if ( ! function_exists('force_download')) } // Load the mime types - if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) - { - include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); - } - elseif (is_file(APPPATH.'config/mimes.php')) - { - include(APPPATH.'config/mimes.php'); - } + $mimes =& get_mimes(); // Only change the default MIME if we can find one if (isset($mimes[$extension])) @@ -101,6 +94,9 @@ if ( ! function_exists('force_download')) $filename = implode('.', $x); } + // Clean output buffer + ob_clean(); + // Generate the server headers header('Content-Type: '.$mime); header('Content-Disposition: attachment; filename="'.$filename.'"'); |