RE: [PHP] Fooling the client into thinking php script is .jpg

From: Date: Mon, 11 Feb 2002 14:21:26 +0000
Subject: RE: [PHP] Fooling the client into thinking php script is .jpg
Groups: php.general 
Request: Send a blank email to php-general+get-84267@lists.php.net to get a copy of this message
There's a very simple way of doing this. <img border="0" src="image.php"> This should make the browser call the php file and it will return an image. -----Original Message----- From: Christopher William Wesley [mailto:cwwesley@udlug.org] Sent: Monday, February 11, 2002 12:36 AM To: php-general@lists.php.net Cc: Matt Moreton Subject: Re: [PHP] Fooling the client into thinking php script is .jpg On Mon, 11 Feb 2002, Matt Moreton wrote: > I have a script that outputs an image. Using the gd library. But the ... > the image. Is it possible somehow to request the file as a .jpg? > www.host.com/displayimage.php Assuming you're using Apache, you can use a rewrite rule (with mod_rewrite). http://httpd.apache.org/docs/mod/mod_rewrite.html Turn the rewrite engine on, then specify a rewrite rule which tells apache to execute your script when a certain file is requested. Using the file names you specified, add this to your httpd.conf (or your .htaccess): RewriteEngine on RewriteRule ^/displayimage.jpg$ /displayimage.php [L] You can then just use /displayimage.jpg as an image src, then when a visitor's browser requests it, apache will execute & return /displayimage.php instead, and the visitor will never know. ~Chris /"\ \ / September 11, 2001 X We Are All New Yorkers / \ rm -rf /bin/laden

« previous php.general (#84267) next »