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的闭包(Closure)匿名函数详解

php的闭包(Closure)也就是匿名函数,是PHP5.3引入的。 闭包的语法很简单,需要注意的关键字就只有use,use是连接闭包和外界变量。 复制代码 代码如下: $a = fun...

php阿拉伯数字转中文人民币大写

本文实例为大家分享了php阿拉伯数字转中文人民币大写的实现代码,供大家参考,具体代码如下 代码1:php阿拉伯数字转中文人民币大写,有详细的注释 /** *数字金额转换成中文大写金额...

在PHP上显示JFreechart画的统计图方法

如何在PHP上显示JFreechart?可能大部分都遇到这种情况,在JSP上的servlet能完全的显示出JFreechart画的统计图,但是和其他语言混合运用就不能显示了 我现在也遇到...

php魔术变量用法实例详解

本文实例讲述了php魔术变量用法,其中__DIR__是php5.3新增的,分享给大家供大家参考。具体用法分析如下: 系统常量 __FILE__ 当前文件名 __LINE__ 当前行数 _...

win10环境PHP 7 安装配置【教程】

PHP 7出来好一段时间了,前些日子工作比较忙,没时间研究,现在有点时间了,公司里生产环境不能随便升级,家里自己的电脑还是可以装一下看看效果的。 下面简单说明一下PHP 7 + Apac...