I have a PHP script for deleting a directory. This deletes the target directory but shows an error message if there are more than one file but it still deletes the directory..weird..;Shown error given below:-
Warning: rmdir(uploads/dd4a96d6907035a1d011b9394d779d3c) [function.rmdir]: Directory not empty in /home/.../public_html/deletepost.php on line 21
here's php
<?php
$dir = $row['album_path'];
17 foreach(scandir($dir) as $file) {
18 if ('.' === $file || '..' === $file) continue;
19 if (is_dir("$dir/$file")) rmdir_recursive("$dir/$file");
20 else unlink("$dir/$file");
21 rmdir($dir);
22 }
?>
Am I doing anything wrong with the code?