【发布时间】:2014-02-14 19:10:52
【问题描述】:
在使用此 php 代码遍历图像目录时,我需要过滤掉我的 MAC 开发计算机坚持创建的系统文件。
首先我只需要过滤掉
.DS_Store
文件,最近也出现了类似这样的文件:
._.DS_Store
if ($handle = opendir($server_dir)) { //if we could open the directory...
while (false !== ($entry = readdir($handle))) { //then loop through it...
if ( ($entry != ".") && ($entry != "..") && (strpos($entry, ".DS_Store") !== false) && (strpos($entry, "._.DS_Store") !== false) ) { //and skip the . and .. entities
$m .= '
'.$client_dir.$entry.'
';
}
}
closedir($handle);
}
else {
echo("Can't open $dir, does it exist? Does www-user have permission to read it?");
}
我需要过滤掉其他名称的隐藏系统文件还是这两个?
有没有比我这样做更好的处理方式?
【问题讨论】: