summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorytetsuro <phper.0o0@gmail.com>2018-02-01 03:38:00 +0100
committerytetsuro <phper.0o0@gmail.com>2018-02-05 16:12:28 +0100
commita3e36019c787eb87fd0bc2e5ba9948c85c4a2c44 (patch)
tree18f4c990092571cb9e22b995e88adc47cd816bc6 /system/helpers
parent719e4acbafecbef3f143affb45a8dcd90945dd04 (diff)
change filename. convert to utf-8
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/download_helper.php17
1 files changed, 16 insertions, 1 deletions
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 338725477..93d468421 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -147,9 +147,24 @@ if ( ! function_exists('force_download'))
@ob_clean();
}
+ $utf8_filename = $filename;
+ $encoding = config_item('charset');
+ if (strtoupper($encoding) !== 'UTF-8')
+ {
+ if (MB_ENABLED)
+ {
+ $utf8_filename = mb_convert_encoding($utf8_filename, 'UTF-8', $encoding);
+ }
+ elseif (ICONV_ENABLED)
+ {
+ $utf8_filename = @iconv($encoding, 'UTF-8', $utf8_filename);
+ }
+ }
+
// Generate the server headers
header('Content-Type: '.$mime);
- header('Content-Disposition: attachment; filename="'.$filename.'"; filename*=UTF-8\'\''.rawurlencode($filename));
+ // charset attribute (RFC 6266 only allows UTF-8)
+ header('Content-Disposition: attachment; filename="'.$filename.'"; filename*=UTF-8\'\''.rawurlencode($utf8_filename));
header('Expires: 0');
header('Content-Transfer-Encoding: binary');
header('Content-Length: '.$filesize);