Reputation: 11
Im trying to use the php function 'readfile(path_to_image)' to dynamically display an image. While its working with php script file encoded as ANSI, it fails when the same script file encoded in UTF-8 (or even included in a file that uses UTF-8). Any idea how to solv this?
Sorry, the code is as follow:
header('Content-Type: image/jpeg');
readfile('C:\wbs\uploads\admin\Koala.jpg');
As I said it works when file is ANSI, saving it as UTF-8 and it fails.
Thanks, David
Upvotes: 0
Views: 992
Reputation: 449515
One wild guess would be that your IDE stores files as UTF-8 with a BOM. The BOM will be interpreted as output by PHP, which will prevent the content-type header from being sent, and everything goes pear shaped from there.
You should be encountering output already sent
warnings if this is the case. Try turning error reporting on if you see nothing.
If this is the case, saving the file without the BOM would solve it.
Upvotes: 4