Hello

I am in a bit bother at the moment, I have an application where I add a contact and at the same time I upload an image to the images directory.

Basically I have a feature where you can delete a contact and what I want to be able to do is to delete the image uploaded in the add contact section.

I have added the file name to the mysql database but havent included the directory. How do I go about deleting a file once the image has been uploaded based on the data in the contacts table which has the file name I want to delete.

If anyone could help it would be much appreciated.

Regards
Chris

Firstly get the file name from the DB, then concat the directory name with the file name and then pass to the unlink() fucntion.
Suppose $dir variable is having the path to the directory and $file_name is having the file name returned from the DB ...

$dir = "../images";
$file_name = "image_name.jpg";
$complete_path = $dir."/".$file_name;
if(unlink($complete_path)){
      //Successfully deleted the file
} else {
      //File not deleted
}

Hope it helps!