php递归删除文件夹
function deldir($dir) {
//先删除目录下的文件:
$dh=opendir($dir);
while ($file=readdir($dh)) {
if($file!="." && $file!="..") {
$fullpath=$dir."/".$file;
if(!is_dir($fullpath)) {
unlink($fullpath);
} else {
deldir($fullpath);
}
}
}
closedir($dh);
//删除当前文件夹:
if(rmdir($dir)) {
return true;
} else {
return false;
}
}
递归删除文件夹
posted on 2014-08-27 11:03 chenzhaojx 阅读(123) 评论(0) 收藏 举报
浙公网安备 33010602011771号