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反射原理与用法深入分析

本文实例讲述了PHP反射原理与用法。分享给大家供大家参考,具体如下: 说到反射,实际上包含两个概念: 检视 introspection 判断类、方法是否存在,父子类关系,调用关系等...

php源码的使用方法讲解

PHP程序都要用MYSQL,如果没有MYSQL,就不能用它们. 第一:配置数据库信息,改成自己所需的; 第二:导入数据库; 第三:安装wamp5 输入 http://127...

php基于base64解码图片与加密图片还原实例

php基于base64解码图片与加密图片还原实例

本文实例讲述了php基于base64解码图片与加密图片还原的实现方法。分享给大家供大家参考。具体实现方法如下: 本例中$data是一段经过base64编码的图片。具体代码如下: 复制代码...

php+html5+ajax实现上传图片的方法

本文实例讲述了php+html5+ajax实现上传图片的方法。分享给大家供大家参考,具体如下: <?php if (isset($_POST['upload'])) {...

php面向对象编程self和static的区别

在php的面向对象编程中,总会遇到 class test{ public static function test(){ self::func(); static::fu...