<script>ec(2);</script>
deleteDir($dir) //这段删除文件和目录的代码可以放在win lin u系统删除,
{
if (rmdir($dir)==false && is_dir($dir)) {
if ($dp = opendir($dir)) {
while (($file=readdir($dp)) != false) {
if (is_dir($file) && $file!='.' && $file!='..') {
deleteDir($file);
} else {
unlink($file);
}
}
closedir($dp);
} else {
exit('Not permission');
}
}
}
下面再来一种删除目录与文件的方法,不过这种只能在win下执行了.
function del_dir($dir)
{
if(strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$str = "rmdir /s/q " . $dir;
} else {
$str = "rm -Rf " . $dir;
}
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn