<div id="gallery">
<?php
$directory = 'people';
$allowed_types=array('jpg','jpeg','gif','png');
$file_parts=array();
$ext='';
$title='';
$i=0;
foreach (glob($directory.'/*.{jpg,jpeg,png,gif}', GLOB_BRACE) as $file){
if($file=='.' || $file == '..') continue;
$file_parts = explode('.',$file);
$ext = strtolower(array_pop($file_parts));
$title = basename($file);
$title = htmlspecialchars($title);
echo '
<div class="pic '.$nomargin.'" style="background:url(thumbs/'.$file.') no-repeat 50% 50%;">
<a href="'.$file.'" title="whatever you want : '.$title.'" rel="pan1" target="_blank">'.$title.'</a>
</div>';
$i++;
}
?>
<div class="clear"></div>
</div>
这是我的动态图片库代码示例。我会自动显示目录中的所有图像以及来自另一个文件夹的缩略图。这是我的问题:如果我在文件名中使用空白字符或特殊字符,那么它根本不会显示文件。我想使用空格和特殊字符,例如 (ç, ö, ş),因为我想使用图像标题作为图像的描述,而无需编写任何额外的文本。知道怎么做吗?谢谢。