//搜索文件夹下全部文件,暂时不支持中文文件名
public function scanFile($path) {
if (!is_dir($path))
return array();
// 兼容各操作系统
$path = rtrim(str_replace('\\','/',$path ),'/').'/';
$result = array();
$files = scandir($path);
foreach ($files as $file) {
if ($file != '.' && $file != '..') {
$file=iconv("gb2312","utf-8",$file);
if (is_dir($path . '/' . $file)) {
$result = array_merge($result, scanFile($path . '/' . $file));
} else {
$result[] = basename($file);
}
}
}
return $result;
}
PHP搜索文件夹下全部文件
转载本文章为转载内容,我们尊重原作者对文章享有的著作权。如有内容错误或侵权问题,欢迎原作者联系我们进行内容更正或删除文章。
上一篇:PHP多文件上传
下一篇:PHP用*隐藏中文问题
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
C#递归获取文件夹下全部文件
很多时候我们需要获取一个结构未知的文件夹下所有的文件或是指定类型的所
C# 递归 List System App