Rmdir-script problems

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?

are you getting errors? if so what errors?

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

Well, it didnt do anything at all. But I tried “unlink” instead of “delete” and got the script running :slight_smile: