Forum Moderators: coopster

Message Too Old, No Replies

file get contents error for local file

special characters in file name

         

jaruba

9:42 pm on Jun 25, 2009 (gmt 0)

10+ Year Member



I made a script to read the file contents of different files on my server.

It works on all files except files with special characters in them (for example: 'Hannah Montana 1x04 A moitié amoureux.avi.torrent' or 'Hannah Montana 1x03 Chassé-Croisé.avi.torrent') wich give me a
'Warning: file_get_contents(Hannah Montana 1x03 Chassé-Croisé.avi.torrent) [function.file-get-contents]: failed to open stream: No such file or directory in /home/content/f/a/n/fantomul/html/new_tors/read.php on line 40'
error

The path to those files is correct, i'm looking for a way to escape those special characters in such a way for the file_get_contents function to work on them.

Any help would be much appreciated. Thank you in advance.

Little_G

9:58 pm on Jun 25, 2009 (gmt 0)

10+ Year Member



Hi,

After some testing using utf8_encode [php.net] worked for me.

Andrew

jaruba

11:11 pm on Jun 25, 2009 (gmt 0)

10+ Year Member



Thank you for the quick reply.

It seems that the file name was encoded in utf8 already and i needed to use utf8_decode for the file_get_contents function to work properly for some reason.

It's working perfectly now, i greatly appreciate the help.