Open file with special charaters

Topics: Developer Forum
Sep 25, 2014 at 9:31 AM
Edited Sep 25, 2014 at 9:44 AM

I use PHPExcel since one week and i meet a problem yesterday.
I've try to open a file name "testé.xlsm" but apparently the "é" give me problem.
When i try to open this file i've got an error:
"Error loading file "testé.xlsm": Could not open xls/testé.xlsm for reading! File does not exist."

But i'm sure it exists and in the good folder.

  • Windows 7,
  • PHP 5.3.9,
  • Apache2.2.25,
  • PHPExcel 1.8.0, 2014-03-02
If you can help me :) Thanks.

PS: Sorry for my english, not my native language.
Sep 25, 2014 at 10:21 AM
This is not a PHPExcel issue, but a filesystem issue..... it's never a good idea to use non-ASCII characters in filenames unless you know execatly what you're doing, and have full control of your operating environment, because it will depend on the charset that your filesystem is configured to use.... in most cases, this will be ASCII
Sep 25, 2014 at 10:28 AM
Edited Sep 25, 2014 at 10:28 AM
MarkBaker wrote:
This is not a PHPExcel issue, but a filesystem issue.....
I suspected that... :/

I'm agree that it's not a good idea but i haven't control on the filename.

Thanks for your response, i will search about chartset now.
Sep 25, 2014 at 11:36 AM
I've found a solution.
$fileName = 'xls/testé.txt';
$fileName = mb_convert_encoding ($fileName,'CP1252', 'utf-8');
It converts $fileName from type of encoding 'CP1252' (which is a Windows encoding...) to 'UTF-8' more classic.

Now it work !
Marked as answer by Nato24C on 9/25/2014 at 3:38 AM