delete($path . '/' . $file, $recursive); } } else { unlink($path . '/' . $file); } } } closedir($dir); rmdir($path); } else { unlink($path); } } }