From 2ad0b3553121ea2e5951179ac0aaca8fc71b767b Mon Sep 17 00:00:00 2001 From: Mehdi Bounya <5004111+mehdibo@users.noreply.github.com> Date: Wed, 31 Jan 2018 04:43:37 +0000 Subject: File name changing in dynamic output Allow changing file name (`Content-Disposition` header) when outputting the image by specifying the `new_name` config --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 63e071e7c..f7b66c72e 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1548,7 +1548,7 @@ class CI_Image_lib { */ public function image_display_gd($resource) { - header('Content-Disposition: filename='.$this->source_image.';'); + header('Content-Disposition: filename='.( (empty($this->new_image)) ? $this->source_image : $this->new_image ).';'); header('Content-Type: '.$this->mime_type); header('Content-Transfer-Encoding: binary'); header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT'); -- cgit v1.2.3-24-g4f1b From 10cc80e9f35aac497fe5b60b3e409a213a5a5291 Mon Sep 17 00:00:00 2001 From: Mehdi Bounya <5004111+mehdibo@users.noreply.github.com> Date: Wed, 31 Jan 2018 22:44:16 +0000 Subject: Update Image_lib.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I didn't understand #5394 that well, what I understood from your comment is that we should convert the charset to UTF-8. I tested with **マルチバイト** but it outputs nothing (empty string), but when I add a character **before** the string (e.g. xマルチバイト) it worked fine. --- system/libraries/Image_lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index f7b66c72e..b5e86f8a7 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1548,7 +1548,8 @@ class CI_Image_lib { */ public function image_display_gd($resource) { - header('Content-Disposition: filename='.( (empty($this->new_image)) ? $this->source_image : $this->new_image ).';'); + $filename = basename(empty($this->new_image) ? $this->source_image : $this->new_image); + header('Content-Disposition: filename='.$filename.'; filename*=UTF-8\'\''.rawurlencode(iconv(config_item('charset'), 'UTF-8', $filename))); header('Content-Type: '.$this->mime_type); header('Content-Transfer-Encoding: binary'); header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT'); -- cgit v1.2.3-24-g4f1b From d4fbb65b9a5c75b00ad8374021c72eb6ff4a58df Mon Sep 17 00:00:00 2001 From: Mehdi Bounya <5004111+mehdibo@users.noreply.github.com> Date: Wed, 7 Feb 2018 18:48:17 +0000 Subject: Changing file name in image lib dynamic output --- system/libraries/Image_lib.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index b5e86f8a7..0c36f740c 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1548,8 +1548,7 @@ class CI_Image_lib { */ public function image_display_gd($resource) { - $filename = basename(empty($this->new_image) ? $this->source_image : $this->new_image); - header('Content-Disposition: filename='.$filename.'; filename*=UTF-8\'\''.rawurlencode(iconv(config_item('charset'), 'UTF-8', $filename))); + header('Content-Disposition: filename='.basename(empty($this->new_image) ? $this->source_image : $this->new_image).';'); header('Content-Type: '.$this->mime_type); header('Content-Transfer-Encoding: binary'); header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT'); -- cgit v1.2.3-24-g4f1b From 06e5d36f566c68b51ded2c2c307094c062e17a10 Mon Sep 17 00:00:00 2001 From: Mehdi Bounya <5004111+mehdibo@users.noreply.github.com> Date: Mon, 12 Feb 2018 19:15:01 +0000 Subject: Update Image_lib.php Fixed indentation --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 0c36f740c..f37f25f5e 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1548,7 +1548,7 @@ class CI_Image_lib { */ public function image_display_gd($resource) { - header('Content-Disposition: filename='.basename(empty($this->new_image) ? $this->source_image : $this->new_image).';'); + header('Content-Disposition: filename='.basename(empty($this->new_image) ? $this->source_image : $this->new_image).';'); header('Content-Type: '.$this->mime_type); header('Content-Transfer-Encoding: binary'); header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT'); -- cgit v1.2.3-24-g4f1b