Why does PHP imagejpeg() returns URL instead of image?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lajollabob
Forum Newbie
Posts: 1
Joined: Tue Jul 29, 2008 8:19 pm

Why does PHP imagejpeg() returns URL instead of image?

Post by lajollabob »

I am trying to just get a simple PHP GD code snippet to work but it does not generate an image, only a text of the URL of the page.

The code is located at: http://www.erightsipo.com/certcreator.php and then generates http://www.erightsipo.com/certcreator.php for the output but it should be a jpeg.

What is wrong with the code?

http://www.erightsipo.com/phptest.php shows that GD is working.


Here is the related PHP info:

GD Support enabled
GD Version bundled (2.0.28 compatible)
FreeType Support enabled
FreeType Linkage with freetype
FreeType Version 2.2.1
GIF Read Support enabled
GIF Create Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

The memory_limit on the site is set to 32M which is more than enough.


?PHP

error_reporting(E_ALL);

header("Content-type: image/jpeg");
$im = imagecreate(200, 200);
$green = imagecolorallocate($im, 0, 255, 0);
imagefill($im, 0, 0, $green);
// no image name
imagejpeg($im, "", 60);
imagedestroy($im);


?>
mabwi
Forum Commoner
Posts: 27
Joined: Wed Aug 01, 2007 4:51 pm

Re: Why does PHP imagejpeg() returns URL instead of image?

Post by mabwi »

Is that code you posted the one that's not working? Because it works properly for me.
Post Reply