Re: IE not showing PHP-generated images, but Firefox does.

Re: IE not showing PHP-generated images, but Firefox does.

am 14.04.2008 16:04:01 von Harlan Messinger wrote:
> I have an image being generated by a PHP script--
> I didn't write the code-- and the image itself is in a
> database.
> I've discovered that there is a big discrepancy
> between how the images appear in IE7 and FF2,
> e.g. for .
> Namely, they appear just fine in Firefox but
> in IE nothing appears at all.
> Can anyone tell me know how to make this work
> and whether this is a browser issue, a PHP issue,
> or what?

A couple of folks are sending you in weird directions that surprise me
because in the absence of more specific information from you, your
question happens to have a single *likely* answer, one that has been
discussed in the HTML groups before.

And, no, it isn't a browser-side problem, even if there is one browser
that happens to get the right answer.

You didn't say what kind of image you're sending. How do you think a
browser knows what kind of image it is receiving, in order to be able to
render it? The answer is that the server sends along a Content-type
header. Web servers are typically configured to send JPEG files as

Content-type: image/jpeg

while GIF files are marked "image/gif", etc.

The server will typically be configured to mark responses generated by
PHP files as "text/html" or some XHTML-related type, depending on the
configuration. If instead you are using a PHP file to generated binary
data, then you need, in your PHP code, to set the content-type
explicitly to the right type for your image. Otherwise the browser has
to guess, making whatever choice it's been programmed to make.