/** * 递归删除目录中文件 * @param $pathname * @return bool */ public static function delDir($pathname)//要删除的目录 { if(file_exists($pathname)) { if(is_file($pathname)) { unlink($pathname); } else { $dir = opendir($pathname); while($filename = readdir($dir)) { if($filename != "." && $filename != "..") { $filename = $pathname . "/" . $filename; if(is_dir($filename)) { self::delDir($filename); } else { unlink($filename); } } } closedir($dir); rmdir($pathname); } } return true; }