Re: Image and PHP

From: Date: Thu, 14 Apr 2005 14:11:18 +0000
Subject: Re: Image and PHP
Groups: php.general 
Request: Send a blank email to php-general+get-213086@lists.php.net to get a copy of this message
--- Mario de Frutos Dieguez <marfru@cartif.es> wrote: > I have a page where i place an image but i want when > i show the image delete it. How can i do this? Some good suggestions so far but to be a little more explicit this is how you would do it. Essentially you want to have your image tag point to a script, have that script pass the image to the browser then delete the image. Please note, this example code, for simplicity sake, leaves out any security precautions. On you main page you'll have an image tag like: <img src="show_image.php?image_name=some_image.jpg"> Then show_image.php will look something like this: <?Php $filepath = $_GET['image_name']; $fd = fopen($filepath,'r'); fpassthru($fd); fclose($fd); unlink($filepath); ?> Remember though, as written you need to do some validation on $filepath, because as is, this script will pass anything to the user that is contained in $_GET['image_name'] then delete it, so be careful. -k. __________________________________ Do you Yahoo!? Yahoo! Small Business - Try our new resources site! http://smallbusiness.yahoo.com/resources/

« previous php.general (#213086) next »