View Full Version : Delete external files... but there is a trick

12-02-2006, 06:22 PM
I have soe files in mywebsite that say they aren't there, so it wont let me delete them... however when I tried a delete/unset script it didnt do anything.

does anyone know how to make a script so that I cna just completely kill the directory they are contained in, since it can still find that directory?

like the files are in like

and the files are a file named "1", no extensions or anyhthing, and a directory with a shortcut icon (the little arrow in the corner) that is simply named "."

they were put there when I messed up on a php script... is there a script that will just completely kill the directory /testing so that I can remake the directory and put in my files?

12-02-2006, 06:31 PM
I've used this function in a filemanager that I was working on, but never finished. Feel free to modify it to your liking.

$home = "/home/www/mysite/"; //the path to your folder

remove_directory('testing'); /* call the function with the desired folder you wish to delete */

function remove_directory($fold) {
global $home;

if(substr($fold, -1, 1) == "/"){
$fold = substr($fold, 0, strlen($fold) - 1);
if ($open = opendir($home.$fold)) {
while (false !== ($item = readdir($open))) {
if ($item != "." && $item != "..") {
if (is_dir($home."$fold/$item")) { remove_directory("$fold/$item"); }
else { unlink($home."$fold/$item"); }


12-02-2006, 07:11 PM
yay it worked... is that copyrighted or can i give it to other people if they need help wiht that?

and thanks for all your help... you seem to be the only one that ever helps me

12-02-2006, 07:33 PM
The above is not copyrighted. I made that function up while working on a File Mananger program, that I never completed. You can give it out to other people and change to your liking.


12-02-2006, 09:43 PM
okay. Thanks to you I have succesfully deleted and remade the directory... Otherwise I would have had to do an hours worth of work changing urls all over my site.


12-03-2006, 12:23 AM
Not a problem at all, let me know if you need any more help.