php 显示指定路径下的图片
更新时间:2009年10月29日 22:13:48 作者:
给一个路径,得到她下面的图片,并显示出来的php代码。
复制代码 代码如下:
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;
}
相关文章
PHP 字符串加密函数(在指定时间内加密还原字符串,超时无法还原)
最近, 从discuz里面发现了一个很牛的加密解密函数。此函数的厉害之处在于可以在指定时间内加密还原字符串,超时无法还原.2010-04-04


最新评论