Hi,
I've a big problem. I need delete a non-empty directory by PHP. I try using system("rmdir dirname -r") but this function isn't work :-( Can anybody help me how can I delete directory with files and subdirectories (non-empty dir) ?
Thanks,
Jiri Eger jiri@eger.cz
Assuming you've linux as your os, try: <B>rm -rf dirname</B>
Yes I've a Linux. I know linux commands very good. I don't need delete non-empty dir from linux shell but I need delete non-empty dir by PHP script in web page !!! It's not functional !!
Thanks
Assuming you have the appropiate permission to delete the directory, using exec(...) should work just fine.
<?php exec("rm -rf $dirname", $Output,$ReturnVal); ?>
There is a php boolean command called "rmdir".
The usage is -
if(rmdir("/path/to/your/dir")) { echo("Dir Removed Ok"); } else { echo("Dir Was Not Removed"); }
It always pays to look at the manual
-Alex Augot Teradyne, Inc
Hmm :-( I know PHP command rmdir but this command can delete ONLY EMPTY dir but if you try delete non empty dir you get message that you cannot remove non-empty dir :-(( I've very complicate directory structure in directories which I need delete. And it's for users by web script :-(
Hmm. Thanks, but I try this and it's without reaction. After run script with function exec("rmdir -rf $dirname", $Output,$ReturnVal); $Output array variable is empty and $ReturnVal variable return 1. But directory specified in $dirname variable isn't deleted.
:-((
Jiri Eger