Welcome Guest, Not a member yet? Register   Sign In
Codeigniter Email Attachment name not support Unicode?
#1

(This post was last modified: 03-03-2018, 03:15 PM by squashking.)

Hi, I tried sending an attachment containing Unicode characters, and the attachment was  sent successfully. But the Unicode characters were removed from the file name. For example, if I send an attachment named "你好.jpg", then the receiver will receive the file but it's named ".jpg" (unicode characters are removed). I want to keep the original attachment name, is there any solution? Thank you very much!

Code:
$this->email->attach("path/to/你好.jpg"); //attachment name contains Unicode characters
Reply
#2

This may help you understand what is going on.

Filesystem encoding and PHP
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(03-04-2018, 05:09 AM)InsiteFX Wrote: This may help you understand what is going on.

Filesystem encoding and PHP

Thank you, is there any solution if I want to use Unicode file name? It does not make sense the file name cannot use Unicode characters.
Reply
#4

I think they said that the new international php 7+ should work now,
not sure so you would need to check php.net
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(03-05-2018, 04:03 AM)InsiteFX Wrote: I think they said that the new international php 7+ should work now,
not sure so you would need to check php.net

Thank you. I believe there should be other solutions instead of upgrading PHP version. After all, having Unicode file name is very common and is very necessary in many cases.
Reply
#6

(03-05-2018, 04:32 AM)squashking Wrote:
(03-05-2018, 04:03 AM)InsiteFX Wrote: I think they said that the new international php 7+ should work now,
not sure so you would need to check php.net

Thank you. I believe there should be other solutions instead of upgrading PHP version. After all, having Unicode file name is very common and is very necessary in many cases.

Actually, if that was the problem, you wouldn't just have stripped unicode characters from the filename; you'd have no attachment at all. Please test and tell me if this works (so I can merge it into the main code tree): https://github.com/bcit-ci/CodeIgniter/c...1738c5b569

BUT! Do your PHP upgrade, ASAP. Don't look for excuses to avoid it.
PHP 5 is no longer supported and only 5.6 is receiving security patches until the end of this year, and that's on par with 7.0!

https://secure.php.net/supported-versions.php

Yes, even PHP 7.0 is old news now. Don't delay those upgrades, it doesn't do you any favors.
Reply
#7

Thanks. I finally solved the problem, just by adding the 3rd parameter to $this->email->attach(para1, para2, para3). Set the 3rd parameter to the Unicode name it will work.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB