Sleep Mode
08-02-2006, 01:48 PM
Hi. Im using the rmdir function but it gives an error and says that the directory is not empty. How can i remove a directory that is not empty?
|
Click to See Complete Forum and Search --> : [RESOLVED] Problem about rmdir function Sleep Mode 08-02-2006, 01:48 PM Hi. Im using the rmdir function but it gives an error and says that the directory is not empty. How can i remove a directory that is not empty? NogDog 08-02-2006, 05:04 PM <?php function remove_dir($dir) { if(is_dir($dir)) { if(is_writeable($dir)) { $files = glob("$dir/*"); foreach($files as $file) { if(is_dir($file)) { if(!remove_dir($file)) // recursion fun! { return(FALSE); } } else { if(is_writeable($file)) { if(!unlink($file)) { user_error("Unable to delete $file", E_USER_WARNING); return(FALSE); } } else { user_error("$file is not writeable", E_USER_WARNING); return(FALSE); } } } if(!rmdir($dir)) { user_error("Unable to delete directory $dir", E_USER_WARNING); return(FALSE); } } else { user_error("$dir is not writeable", E_USER_WARNING); } } else { user_error("$dir is not a directory", E_USER_WARNING); return(FALSE); } return(TRUE); } Sleep Mode 08-02-2006, 07:40 PM That works! Thank youuu! :) webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |