chdir(".") 进入当前路径 :) chdir("..") 进入了上级目录!!! 这时候除非你能保证上级目录也有相同的目录,并且之后的chdir能 顺利地碰巧进入读出的路径。还有,php4的正确进行目录读取循环是: <?php $handle=opendir('.'); echo "Directory handle: $handle\n"; echo "Files:\n";/* This is the correct way to loop over the directory. */ while (false !== ($file = readdir($handle))) { echo "$file\n"; }/* This is the WRONG way to loop over the directory. */ while ($file = readdir($handle)) { echo "$file\n"; }closedir($handle); ?>
$tmp=stat($file);
if($tmp[2]<16900)
echo("Directory.");
else
echo("file.");
?>
其中stat是返回文件的所有属性,$tmp[2]是"r/w/x"的属性数,小于某一个数的是目录,否则为文件。PHP在windows和linux之间的东西好象不能分得很开,is_dir(),is_file()不能正确的判断。
另外有可能
$handle=opendir("root");
就已经出错了,你查一下。另外is_dir(),is_file()的参数$file是要绝对路径的应该加上之前的root路径。
chdir("..") 进入了上级目录!!!
这时候除非你能保证上级目录也有相同的目录,并且之后的chdir能
顺利地碰巧进入读出的路径。还有,php4的正确进行目录读取循环是:
<?php
$handle=opendir('.');
echo "Directory handle: $handle\n";
echo "Files:\n";/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "$file\n";
}/* This is the WRONG way to loop over the directory. */
while ($file = readdir($handle)) {
echo "$file\n";
}closedir($handle);
?>