PDA

View Full Version : rmdir-script problems



Danneman
July 17th, 2003, 10:13 PM
Im trying to get this very basic script to work.

It should delete all the files within a specified folder, and then remove the folder itself, but it just wont work.



<?php
// DELETE DIRECTORY (not working)

// Folders name
$Folder = $_POST['NewsPage'];

// Changes folders access rights
chmod($Folder, 0777);

// Checks if really a folder
if (is_dir($Folder)) {
// Opens folder
$handle = opendir($Folder);
// Reads folders content
while($filename = readdir($handle)) {
if (($filename != ".") && ($filename != "..")) {
// Deletes files
delete($Folder."/".$filename);
}
}
closedir($handle);
// Now that folder empty - delete it too
rmdir($Folder);
}
else {
unlink($Folder);
}

?>


Any ideas?

Jubba
July 17th, 2003, 11:05 PM
are you getting errors? if so what errors?

if not then what does the script do? anything at all?

Danneman
July 18th, 2003, 09:23 PM
Well, it didnt do anything at all. But I tried "unlink" instead of "delete" and got the script running :)