使用此php代码循环访问图像目录时,我需要过滤掉我的MAC dev计算机坚持创建的系统文件。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?");
}
有没有的,我需要隐藏的系统文件的任何其他名称要过滤掉还是这两个呢?
有没有更好的方式来处理这个问题?
也看到这个问题和答案:http://stackoverflow.com/questions/8532569/exclude-hidden-files-from-scandir-php –