PHP remove non-empty directory using Window Command.

PHP remove non-empty directory using exec windows command. On window operating system when we try to remove non-empty directory every time we get the “directory is not empty.” message when we try to remove directory using PHP.

Let’s see how we can remove non-empty directory using exec window command.

exec(‘attrib -r -a -s -h folderpath /s /d’);
exec(‘rd /s /q folderpath’);

Using above exec command we can remove the non-empty directory.

If you face any issue after using this code please write comment below.