View Single Post
Old 27-Feb-2007, 04:38 AM   #1 (permalink)
Sangeetha
Fixed Error!
 
Sangeetha's Avatar

Posts: 139
Location: Chennai
Join Date: Feb 2007
Rep Power: 2 Sangeetha is on a distinguished road

IM:
Default Delete file from directory listing

I'm using the following script, modified from elsewhere, to list off the files in a directory for download. Now I'd like to modify it so you can delete a file by clicking on it (or on a link next to it).

I'm a php novice, so any help would be appreciated.

<?
$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) {
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='$dl/$file'>$file</a></center></td></tr>";
}
}
$list .= "</table>";
echo $list;
echo"
<br><br>

</body>
</html>";
break;

}
?>
Sangeetha is offline   Reply With Quote