SoulEyes Photography
*SoulEyes Photography>>>Photo Gallery

PHP delete image file.?



Okay here is my problem. I have an image gallery and would like the admin to be able to delete certain photos without having to connect to the ftp server. how can I attatch unlink() to a button or link. so when they click on the button it deletes the file?

The following code is insecure; make sure your admin is somehow authenticated, because anyone using this script will be able to delete your images.

This code also assumes all images are in the same directory.

Under each image, have a link that will redirect the user to a file named imagedelete.php?imgid=ID, where ID is the name of the image to be deleted.

imagedelete.php:

<?
if(!isset($_GET['imgid']) || $_GET['imgid'] == '') {
die('No get parameter!');
}

$path = "/physical/path/to/image/folde...

$imgfile = $path . $_GET['imgid'];

if(!is_file($imgfile)) {
die('No such image file: ' . $imgfile);
}

if(unlink($imgfile)) {
header('Location: previouspage.php');
}
else {
die('Cannot delete file: ' $imgfile);
}
?>
Tags
Photography School Photography Magazine Photography Jobs Photography Equipment Photography Courses Photo Gallery Photo Essays Art Gallery Wedding Photography Stock Photography
Related information
  • Baby shower cakes?
  • Need names for 10 older Lego Bionicle sets that I'd like to list online. Already checked Lego.com.?
  • Why can't I add a picture to my profile????
  • GUYS Whos Hotter? PIXX INCLUDED..RATE EM!?
  • Whos Prettier and Has Better Fashion Sence? PIXX INCLUDED..!?
  • HELLO, can any body tell me where are the Planes?
  • Should I get this cut?
  • HEY U! Can you help me out on this myspace problem?
  •  

    Photography Categories--Copyright/IP Policy--Contact Webmaster