Jump to content

Filename setting in Header for GD creations


phat_hip_prog

Recommended Posts

Hi,

I'm generating images by way of GD, but when it's saved through the browser it has the php script's name (e.g. 'genimg.php'). Therefore i'm trying to set the name using 'header()', i'm not sure if this is the way to do it since it's not working. I used the 'filename' bit from 'attachment'. e.g:

..
	header("Content-type: image/png; filename=\"img.png\"");
	$im = ImageCreate(200, 200);
	$black = ImageColorAllocate($im, 0, 0, 0);
	$red = ImageColorAllocate($im, 255, 0, 0);
	ImageFilledRectangle($im, 0, 0, 200, 200, $black);
	ImageFilledRectangle($im, 25, 25, 75, 75, $red);
	# Output the image to the browser
	ImagePng($im);
..

 

Any suggestions?

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.