Use PHP to recursively delete the entire folder. If there is anything wrong, please advise us.
/* ** Traverse Delete Folder ** @param $dir folder to delete folders */ public function del_dir ($dir) { $flag = $this->is_empty_dir ($dir); if ( $flag ==false ) { $DP = opendir ($dir); while (false !== $file = readdir ($DP)) { if ($file != "." && $file != "..." ) { if ( is_dir ("$dir/$file") ) { $this -> del_dir ("$dir/$file" ); }else{ unlink ("$dir/$file"); } } } closedir ($DP); rmdir ($dir); }else{ &nbsP; rmdir ($dir); } } /* ** determine if the folder is empty ** @param folder to be judged */ public function is_empty_dir ($dir) { $flag = true; if ( Is_dir ($dir) ) { $DP = Opendir ($dir); while (false !== $file = readdir ($DP)) { if ($file != "." && $file != "..") { $flag = false; } } return $flag; }else{ echo "Not dir"; } }
PHP Recursive Delete folder