diff options
author | Roger Herbert <rogerlherbert@gmail.com> | 2012-03-14 09:37:06 +0100 |
---|---|---|
committer | Roger Herbert <rogerlherbert@gmail.com> | 2012-03-14 09:37:06 +0100 |
commit | a5c8a6d0fb7802aaf284b7b3ef77966f43baae56 (patch) | |
tree | 12163c9d08070e73b025dd0a6fc602bccc606e90 /system/helpers/download_helper.php | |
parent | b81f909f8aaa3bedc3820c0d4c9056b57113b46e (diff) | |
parent | ce707b4cafd64b95031690cf927584b1d60c7ad7 (diff) |
timespan() helper change
Diffstat (limited to 'system/helpers/download_helper.php')
-rw-r--r-- | system/helpers/download_helper.php | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index f3f0ff2ca..96ff29dec 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -60,19 +60,19 @@ if ( ! function_exists('force_download')) // Set the default MIME type to send $mime = 'application/octet-stream'; + $x = explode('.', $filename); + $extension = end($x); + if ($set_mime === TRUE) { - /* If we're going to detect the MIME type, - * we'll need a file extension. - */ - if (FALSE === strpos($filename, '.')) + if (count($x) === 1 OR $extension === '') { + /* If we're going to detect the MIME type, + * we'll need a file extension. + */ return FALSE; } - $extension = explode('.', $filename); - $extension = end($extension); - // Load the mime types if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { @@ -90,6 +90,18 @@ if ( ! function_exists('force_download')) } } + /* It was reported that browsers on Android 2.1 (and possibly older as well) + * need to have the filename extension upper-cased in order to be able to + * download it. + * + * Reference: http://digiblog.de/2011/04/19/android-and-the-download-file-headers/ + */ + if (count($x) !== 1 && isset($_SERVER['HTTP_USER_AGENT']) && preg_match('/Android\s(1|2\.[01])/', $_SERVER['HTTP_USER_AGENT'])) + { + $x[count($x) - 1] = strtoupper($extension); + $filename = implode('.', $x); + } + // Generate the server headers header('Content-Type: '.$mime); header('Content-Disposition: attachment; filename="'.$filename.'"'); |