|
Posted by Chung Leong on 03/02/06 15:31
cman wrote:
> does anyone know why i can't generate images with:
> header("Content-type:image/jpeg");
> imagejpeg($img_number);
>
> i've tried different examples but i always get a text output as if the
> header doesn't make a difference at all.
>
> <?php
> //random_number.php
> $img_number = imagecreate(100,50);
> $white = imagecolorallocate($img_number,255,255,255);
> $black = imagecolorallocate($img_number,0,0,0);
> $grey_shade = imagecolorallocate($img_number,204,204,204);
>
> imagefill($img_number,0,0,$grey_shade);
> ImageRectangle($img_number,5,5,94,44,$black);
> ImageRectangle($img_number,0,0,99,49,$black);
>
> header("Content-type:image/jpeg");
> imagejpeg($img_number);
> ?>
You must be testing the code using IE, which has a stupid mime-type
caching mechanism. If your script had initially produced an error
message, IE will keep seeing the contents as text.
Try testing the script again.
Navigation:
[Reply to this message]
|