Skip to content

Instantly share code, notes, and snippets.

@greg-randall
Last active July 8, 2019 18:59
Show Gist options
  • Save greg-randall/b852591c02af7b4ce1197a7f6d1e5e32 to your computer and use it in GitHub Desktop.
Save greg-randall/b852591c02af7b4ce1197a7f6d1e5e32 to your computer and use it in GitHub Desktop.
This tries to delete everything in it's directory and lower -- files and folders. I made this to delete some files with weird names that I couldn't delete over FTP. It will probably delete itself. Be really really sure you want this before you do this.
<pre>
<?php
//ARE YOU SURE YOU WANT TO DELETE EVERYTHING???
$rii = new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.'));
foreach ($rii as $file) {
echo $file->getPathname() . "<br>";
rmdir(realpath($file->getPathname()));
unlink(realpath($file->getPathname()));
system("rm -rf " . realpath($file->getPathname()));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment