FTP没权限直接删除目录,写的一个小工具循环删除

时间:2024-06-23 19:05:08
$path = '/var/www/html/Runtime/';

$ite = new RecursiveDirectoryIterator($path);
foreach (new RecursiveIteratorIterator($ite) as $filename=>$cur) {
$fn = $cur->getBasename();
if($cur->isDir() || ($fn == '.' || $fn == '..')) continue;
unlink($filename);
} del_dir($path); function del_dir($path){
$filenames = scandir($path);
for($i=0;$i<count($filenames);$i++) {
$filename = $filenames[$i];
$url = $path.$filename."/";
if($filename == '.' || $filename == '..') continue;
del_dir($url);
rmdir($url);
}
rmdir($path);
}
echo "success!";