PHP 遍历XP文件夹下所有文件


复制代码 代码如下:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
//PHP遍历文件夹下所有文件
$handle=opendir('C:\\'); //我要遍历C盘的文件
echo "目录 handle: $handle <br/>";
echo "文件: <br/>";
while ($file =readdir($handle)) {
$file=iconv('GB2312','UTF-8',$file);//将XP的gbk编码转成UTF8
echo "$file <br/>"; //输出文件名
}
closedir($handle);
?>

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3