Hi All.

I am currently designing a photo sharing website. I need to make a script that deletes the image from the folder it is stored in and also from the database. I have done the database bit but i cannot work out the deleting from the folder bit.

Any help would be much appreciated.
Thanks in advance,

To delete a file (i.e. image in a folder), use the PHP function unlink:

if( unlink('/path/to/file/imagenn.jpg') ) {
 // File delete worked
else {
 // File delete failed

To delete the entry from the database and remove the associated photo or file use the following code

// The code assumes that you are deleting multiple entries at once using check-box, so it is looping.. 
	$qry=mysql_query("select * from TABLE where id='$id'");

	if($row["photo"]!="") {  
	if($row["file"]!="") {  
// Delete the entry from the database
$delete="Delete from TABLE where id='$id' ";
print "Entry delete success";
print "Entry delete failed";