Re: Image and PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 --- Mario de Frutos Dieguez <marfru@xxxxxxxxx> 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/ 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux