thinkphp3.2 删除缓存文件

//删除后台缓存
public function ajaxcleanCache(){
$dir = "./Application/Runtime/Logs/Admin/";
if($this->deldir($dir)){
echo 1;die;
}else{
echo 2;die;
}

}

public 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;
}
}

猜你喜欢

转载自www.cnblogs.com/dalaowang/p/9767077.html