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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s