<?php
$action = (isset($_GET['action'])) ? $_GET['action'] : "";
$extlimit = "yes"; //Do you want to limit the extensions of files uploaded
$limitedext = array(".gif",".jpg",".png",".jpeg",".zip",".pdf"); //Extensions you want files uploaded limited to.
$sizelimit = "no"; //Do you want a size limit, yes or no?
$sizebytes = "200000"; //size limit in bytes
$dl = "
http://www.mysite.com/uploads/"; //url where files are uploaded
$absolute_path = "mypath/uploads"; //Absolute path to where files are uploaded
$websiteurl = "
Free Web Space and Site Hosting"; //Url to your website
$websitename = "MySite";
switch($action) {
case "delete":
$delfile = $_GET['delfile'];
unlink ($dl . "/" . $delfile);
echo "
<html>
<head>
<title>Delete File</title>
</head>
<body>
<B>File $dl/$delfile has been succesfully deleted.</B><BR><BR>
<a href=$websiteurl>Return to $websitename</a>";
break;
default:
echo "
<html>
<head>
<title>File Download</title>
</head>
<body> <a href=$websiteurl>Return to $websitename</a>";
$list = "<table width=700 border=1 bordercolor=#000000 style=\"border-collapse: collapse\">";
$list .= "<tr><td width=700><center><b>Click To DELETE FILE</b></center></td></tr>";
$dir = opendir($absolute_path);
while($file = readdir($dir)) {
if (($file != "..") and ($file != ".")) {
$list .= "<tr><td width=700>><a href='" . $_SERVER['PHP_SELF'] . "?action=delete&delfile=$file'>$file</a></center></td></tr>";
}
}
$list .= "</table>";
echo $list;
echo"
<br><br>
</body>
</html>";
break;
}
?>
I've tested it on my system and it actually deletes the file.