Because PHP rmdir can only delete empty folders.
Once you delete a folder with files, you need to delete the files in the folder first.
Of course, there are folders in the folder, there are folders below .... How to do it.
Recursive deletion method to solve this problem perfectly. On the Code
functionRmfile ($dir){ if(!file_exists($dir))Echo"File does not exist!"; if($file _dir=Opendir($dir)) { while(($sun _file=Readdir($file _dir)) !=false) { if($sun _file!== '. ' &&$sun _file!== ' ... ') { if(Is_dir("$dir/$sun _file") {rmfile ("$dir/$sun _file"); } Else { unlink("$dir/$sun _file"); } } } } Closedir($file _dir); rmdir($dir);} Rmfile ("./dir");
This was written by myself, and one of the others wrote the same principle. can also refer to. It's best to write it all over again.
http://blog.csdn.net/wuxiaopeng_1986/article/details/52956870
PHP Recursive Delete folder