Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php delete a folder

function deleteDirectory($dir) {
    if (!file_exists($dir)) {
        return true;
    }

    if (!is_dir($dir)) {
        return unlink($dir);
    }

    foreach (scandir($dir) as $item) {
        if ($item == '.' || $item == '..') {
            continue;
        }

        if (!deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
            return false;
        }

    }

    return rmdir($dir);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #php #delete #folder
ADD COMMENT
Topic
Name
3+4 =