This is the code I use to delete files:
#set delete function
function delete_file ($filename) {
$file = "/home/public_html/files/".$filename;
if (file_exists($file))
{
unlink("$file");
return ("File $filename has been deleted.");
}else{
return ("$filename could not be found!");
}
}
if ($delete!="") {$delete="";
$delete_complete=1;
}
I use the following link to initiate the deletion process:
<a href="<?php echo $PHP_SELF."?delete=1&filename=$filename"; ?>">DELETE</a>
Hope that helps