Jump to content

Problem Loading PNG File


OtagoHarbour

Recommended Posts

I have a PNG file that exists and can load with Windows Picture and Fax Viewer. I try to display it with PHP using the following code in the file http://localhost/DisplayOrAnalyzeSingleArray.php. $im = imagecreatefrompng($PNGFileName); header('Content-Type: image/png'); imagepng($im); imagedestroy($im); On Firefox, I get the following message.The image ``http://localhost/DisplayOrAnalyzeSingleArray.php'' cannot be displayed because it contains errorsOn Internet Explorer, instead of displaying the image, it just types out a bunch of non-ASCII characters that presumably correspond to the binary data in the image. But it does not display the image.I would be grateful if someone could tell me how I should display a PNG image with PHP.Thanks,Peter.

Link to comment
Share on other sites

The problem sounds like the header isn't set properly. But it looks like you've set it so that can't be the case. So from what I can tell the code given looks flawless. Have you tried different images? Could we see the rest of your code?

Link to comment
Share on other sites

The problem sounds like the header isn't set properly. But it looks like you've set it so that can't be the case. So from what I can tell the code given looks flawless. Have you tried different images? Could we see the rest of your code?
I got it to work but only by removing any html stuff from the code. That included<html><body>...</body></html>Thanks,Peter.
Link to comment
Share on other sites

Well, since it's an image file, it'd be no use also trying to print HTML :). It's the same idea as not putting HTML in a CSS script. Also demonstrates why it is useful to always show all your code.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...