//搜索文件夹下全部文件,暂时不支持中文文件名
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;
}
相关文章: