它把zip,这些文件都读出来了,怎样能让他只读图片不读其他文件你呢...
<html>
<head>
  <title>Browse Directories</title>
  <style type="text/css">
<!--
@import url("style.css");
-->
  </style>
</head>
<body>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#64A7DE">
  <tr>
    <td>
<?php
  $current_dir = 'D:\wwwroot\AppServ\www\mengyu\photo';
  $dir = opendir($current_dir);
  $i=0; 
  while ($file = readdir($dir))
  { $i++; 
     if($i>2) 
      {  echo "";
?>    
        
&nbsp;<?="<a href='photo/$file' target='_blank'>"?><img src='<? echo "photo/$file"?>' width=120 style='border:6px'><?="</a>"?><?     }  } 
//closedir($dir); 
?>
</td>
  </tr>
</table> 
<a href='upload.php' target='_blank'>图片上传</a>
</body>
</html>

解决方案 »

  1.   

    function searchDBbackDocument($forhead,$path)
    {
    if ($handle = opendir($forhead.$path)) 
    {
    while (false !== ($file = readdir($handle))) 
    {
    if ($file != "." && $file != "..") 
    {
    if (eregi('\.(sql|txt)',$file))

    $table=explode('-',$file);
    $val=explode('.',$table[count($table)-1]);
    if ($val[0]==1||$val[1]=='txt')
    {
    $str[]=$file;
    }
    }else{
    $str[]='<a href=?doc='.$path.$file.'/>'.
    '<img src='.$forhead.'images/drive.gif border=0
     width=25 height=15 align=middle> '.$file.'</a>';
    }
    }
    }
    closedir($handle);
    }
    return $str;
    }
    searchDBbackDocument('../','images/');这个只显示  .sql   .txt 和 文件夹 你修改一下这个函数 就可以了!!!