tags:

views:

109

answers:

2

I am trying to delete all contents in specific folder but it doesn't seem to effect subfolder but it should, because bash command does it from console.

system('rm -Rf some_dir/*');
A: 

It's probably because the user executing the script doesn't have privileges for deleting the directory(ies) or the shell isn't in the right directory.

If you're running this via apache, chances are the process is owned by www-data. If the "some_dir" directory doesn't allow for write access by www-data, then it won't work.

Since you're using a relative path (very dangerous), you need to ensure that the script is executing in the correct directory. I'd suggest you change the path to an absolute one if you can - "rm -rf /path/to/some_dir".

hafichuk
A: 

There is no need in asterisk in this command. If you want to remove directory together with files, remove the slash as well. Leaving the slash will delete files, but preserve directory.

Also check comments on this page: http://php.net/manual/en/function.unlink.php

FractalizeR