An image from a website that occasionally comes out as hyroglyphics
Archive - Originally posted on "The Horse's Mouth" - 2011-01-14 18:15:24 - Graham Ellis
Do you have an image that displays perfectly in your browser when you download it from your website ...
... but you get occasional reports from users that it comes out as a string of hyroglyphics for them ...
The problem may be that the server isn't sending the right content-type header, and that most (but not all) browsers will see from the content that the file's not the right type that they have been told, and correct accordingly.
There are four places to check (locations given for the Apache httpd server):
a) the mime.types file in the conf directory of the server, where a line such as image/jpeg jpeg jpg jpe
tells the server to tell the browser that anything with extensions .jpe, .jpg and .jpeg is a jpeg image
b) overrides to the mime.types file in the httpd.conf file (or its included files / modifiers such as .htaccess) such as: AddType image/jpeg .pix
c) The default file type - also in the httpd.conf file: DefaultType image/jpeg hard to thing of a circumstance that you want want this particular default!
d) Within a script (CGI / Perl, PHP, etc) where the image type is set by the script itself. PHP example: header("content-type: image/jpeg");
The examples above come from our training machines, with a variety of browsers. The image was working well on all except one system, where the addition of the header line within the PHP script (which uses the GD library) was necessary for it to render correctly.
Try the example above for yourself ... we have the PHP script that (now) is correct - always adds the header - [here]. It's an unusual script in that - without parameters - it sends an HTML form, but with parameters, it send out an image. I suspect that may have fooled the old browser that had the problem before it was told!