[thelist] Filename on php/gd-generated images

Joshua Olson joshua at waetech.com
Tue May 24 13:13:29 CDT 2005

> -----Original Message-----
> From: Maximillian Schwanekamp
> Sent: Tuesday, May 24, 2005 1:59 PM
> Joshua Olson wrote:
> > You'll want to set the content-disposition header to a 
> value such as this:
> > attachment; filename=imagename.jpg
> Oh yes, but that would initiate a download dialog in most 
> browsers.  

Hi Max,

Replace the attachment with inline, then.  :-)

> I should have been more clear - the script gets called by way 
> of the src  attribute for the image.  e.g.
> <img src="check.php?name=Max+Schwanekamp&amount=900000" height="200" 
> width="400" alt="Pay to the order of... etc" />

In that case, it doesn't matter.  The browser will never open a dialog box.

> Should the user try to save that image from within the web page 
> (right-click...), some browsers will give the file the default name 
> "check.php" and insist that it's a php file, not an image file, which 
> would confuse some users.

Well that's a bugger, ain't it.  Tough to work around that one unless you
change the text in the HTML.

> Misterhaan correctly guessed I'm using apache with 
> mod_rewrite, so his  idea is simple and clean. E.g.
> RewriteEngine on
> RewriteRule check.jpg check.php

There ya go. :-)  URL rewriting is cooler than a cucumber sandwich.

Joshua L. Olson
WAE Tech Inc.
Phone: 706.210.0168 

Monitor bandwidth usage on IIS6 in real-time:

More information about the thelist mailing list