Attempt to delete directory and its hidden files in Linux using php

From the command line when I use:

rm -fr /path/dir/{*,.??*}

I can delete all files in /path/dir, including hidden files, but when I try to do this with PHP using this code:

system('rm -fr /path/dir/{*,.??*}') Nothing happens.

I can not find why this is not working

+4
source share
2 answers

Finally, with this:

system('rm -fr /path/dir && mkdir /path/dir);

I deleted the directory with all its files after creating the directory. And the work is done.

+4
source

If you do not want to delete the directory itself, you do not need to recreate it. This will delete the entire contents of the directory, including hidden files, without warning.

rm -rf ..?* .[!.]* * 
0
source

All Articles