给一个路径,得到她下面的图片,并显示出来

来源:互联网 发布:开通淘宝客要求 编辑:程序博客网 时间:2024/04/29 18:52

 
 function getAllDirAndFile($path)
 {
  if(is_file($path))
  {
   if(isImage($path))
   {
    $str="";
    $str.='<table style="border:solid 1px blue;" width="95%">';
    $str.="<tr>";
    $path=iconv("gb2312","utf-8",$path);
    $str.="<td width=80%>".$path."</td><td  width=15%><img src=".$path." style='width:50px;height:50px;'></td>";
    $str.="</tr>";
    $str.="</table>";
    echo $str;
   }
  }
  else
  {
   $resource=opendir($path);
   while ($file=readdir($resource))
   {
    if($file!="." && $file!="..")
    {
     getAllDirAndFile($path."/".$file);
    }   
   }
  }
 }
 
 function isImage($filePath)
 {
  $fileTypeArray=array("jpg","png","bmp","jpeg","gif","ico");
  $filePath=strtolower($filePath);
  $lastPosition=strrpos($filePath,".");
  $isImage=false;
  if($lastPosition>=0)
  {
   $fileType=substr($filePath,$lastPosition+1,strlen($filePath)-$lastPosition);
   if(in_array($fileType,$fileTypeArray))
   {
    $isImage=true;
   }
  }
  return $isImage;
 }