Skip to content

Instantly share code, notes, and snippets.

@skope
Created April 9, 2014 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skope/15a4fabb271ae0b2b934 to your computer and use it in GitHub Desktop.
Save skope/15a4fabb271ae0b2b934 to your computer and use it in GitHub Desktop.
<?php
include_once(dirname(dirname(__FILE__)) . "/config.php");
$root=WEBSITEROOT_LOCALPATH;
$newfolder = $root . $_POST["folder"];
function remfolder($dir) {
if(!file_exists($dir)) return true;
$cnt = glob($dir . "/" . "*");
foreach ($cnt as $f) {
if(is_file($f)) {
unlink($f);
}
if(is_dir($f)) {
remfolder($f);
}
}
return rmdir($dir);
}
if(file_exists ($newfolder)) {
//delete the folder
remfolder($newfolder);
} else {
//do nothing
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment