Skip to content

Instantly share code, notes, and snippets.

@lgylym
Last active August 29, 2015 14:02
Show Gist options
  • Save lgylym/88f734b9e88c52b6e0ef to your computer and use it in GitHub Desktop.
Save lgylym/88f734b9e88c52b6e0ef to your computer and use it in GitHub Desktop.
delete folder and files created by apache, without the admin privilege.
<html>
<!-- http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-filessub-dirs -->
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
<?php
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
}
}
rrmdir("./example_folder");
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment