![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
![]() |

|
| Knowledge Base Most common error and how to trouble shoot them off |
![]() |
|
Delete file from directory listing
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Fixed Error!
Posts: 141
Location: Chennai
Join Date: Feb 2007
Rep Power: 2
IM:
|
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; } ?> |
|
|
|
|
|
|
|
|
#2 (permalink) |
|
Fixed Error!
Posts: 141
Location: Chennai
Join Date: Feb 2007
Rep Power: 2
IM:
|
$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. |
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|