rmdir-script problems
Posted: Thu Jul 17, 2003 11:05 pm
Hi all!
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.
Any ideas?
Thanks
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.
Code: Select all
<?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);
}
?>Thanks