支持php+asp+mysql+access空间有售。
学习型:98元/半年 个人形象型:100/年 豪华型:280/年 ...
作者 fuzixing 发布于 2003-08-02 分类:php基础编程
unlink可以删除一个文件,,
但是我想将全部文件删除完呢,可以怎么做??
逛论坛交流:请问如何删除一个文件夹中的全部文件??
<?php
$dir = "/tmp/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
unlink($file);
}
closedir($dh);
}
}
?>
Ctrl+A,然后Del
哈哈……
格式化。。。
可以用rename试试
rename("asdf","tmp/asdf");
[php]function rmdirs($file) {
if (file_exists($file)) {
chmod($file,0777);
if (is_dir($file)) {
$handle = opendir($file);
while($filename = readdir($handle)) {
if ($filename != "." && $filename != "..") {
rmdirs($file."/".$filename);
}
}
closedir($handle);
rmdir($file);
} else {
unlink($file);
}
}
}
[/php]
QUOTE: 最初由 巴豆 发布
[B]可以用rename试试
rename("asdf","tmp/asdf"); [/B]
:eek: :eek: :confused: :confused: :blowzy: 改了还有啊
改到其他的目录,不就相当于删除了么,你的Windows的回收站默认的情况下,天天在做这个工作。
7 条回复
回复