My code is as below:
<?php
header("Location: ../");
unlink("index.php");
unlink("style.css");
unlink("success.php");
unlink("fail.php");
unlink("remove.php");
unlink("README.md");
unlink(".gitignore");
unlink(".git");
rmdir("../Humble-Installer");
die();
But every time I run it I receive the following error:
[17-Nov-2014 19:47:37 Pacific/Auckland] PHP Warning: unlink(.git): Operation not permitted in /Users/user/Humble/admin/Humble-Installer/remove.php on line 10
[17-Nov-2014 19:47:37 Pacific/Auckland] PHP Warning: rmdir(../Humble-Installer): Directory not empty in /Users/user/Humble/admin/Humble-Installer/remove.php on line 11
I have no idea, the directory is empty but will not delete... even if I remove the unlink(."git");
it still throws an error?
Cheers.
You can use this simple function to delete folder recursively:
Notes:
unlink
is for a file,.git
is a directory, so it won't remove, usermdir
. If you want to do it recursively, use function I wrote above.Update
If you want to use
RecursiveIteratorIterator
, you can use this function: