Forum Moderators: coopster
i have the following problem:
I create an PNG image into $im.
Then i want to display it in the browser.
And i use the following code:
header("Content-type: image/png");
ImagePNG($im);
Imagedestroy($im);
The problem is that it doesn't show.
If i output it in a file: ImagePNG($im,'file.png'); i can see the correct image in the file, so the code that generates the image in $im is correct.
The problem occurs when i try to output it with headers.
In Mozilla it says: "The image cannot be displayed becauase it contains some errors".
In IE it show the image with an X like it didn't find it.
So it's not just about Mozilla. (I don't have the Skype Add-on).
PS: I tried with ob_start() before the header(), ob_end_flush() at the end. Also with something like :
header('Last-Modified: '.date('r'));
header('Accept-Ranges: bytes');
header('Content-Length: '.$length);
That's because i ouputed the image into a file and looked at it with a photo viewer. The script creates the correct image! I tested the png file created in both browsers and it displays correct too.
The problem is to display it with headers....
<img src="captcha.php"/>Is the path to script correct? src="{_path_}captcha.php"<?php
# captcha.php$im = imagecreatefrompng('file.png');
# (BTW: don't forget do it not cacheable for it can change between page loads)
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
[edited by: NomikOS at 6:23 am (utc) on June 24, 2008]
$im = imagecreatefrompng('file.png');
.
.
.
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>
The script's path is : './captcha.php'.
But either if call directly in the browser it doesn't work.
Only if i put the image to a png file, it shows well.
What can be the problem?
I tried with the headers:
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
and the situation is the same.
Thank you guys for the replies.