php 显示指定路径下的图片

yipeiwu_com6年前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 json格式和js json格式 js跨域调用实现代码

先看一个js函数 复制代码 代码如下: function jsontest() { var json = [{'username':'crystal','userage':'20'},{...

php使用Image Magick将PDF文件转换为JPG文件的方法

本文实例讲述了php使用Image Magick将PDF文件转换为JPG文件的方法。分享给大家供大家参考。具体如下: 这是一个非常简单的格式转换代码,可以把.PDF文件转换为.JPG文件...

解析php中获取系统信息的方法

$root = getenv('DOCUMENT_ROOT'); ////服务器文档根目录$port = getenv('SERVER_PORT'); ////服务器端口$file =...

php投票系统之增加与删除投票(管理员篇)

php投票系统之增加与删除投票(管理员篇)

关于投票系统怎么样怎么样的引言就不多说,这不是毕业设计,主要说一下使用php实现投票系统,与其他普通系统一样,分为两部分,一个是管理员部分,一个是普通用户部分。 关于投票系统的管理部分,...

php分割合并两个字符串的函数实例

本文实例讲述了php分割合并两个字符串的函数。分享给大家供大家参考。具体实现方法如下: 这里实现把两个字符串进行分割合并,例如str1=aaaa,str2=bbbb,合并后生成ababa...