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 之Section与Cookie使用总结

SESSION与COOKIE区别:   Session 将信息保存在服务器上.服务器在接受到唯一的SESSION_ID后,根据这个ID获取相关数据,然后将信息传递到客户端(浏览器).  ...

php正则删除img标签的方法示例 原创

本文实例讲述了php正则删除img标签的方法。分享给大家供大家参考,具体如下: 一、问题 正则抓取过程中需要删除正文中的img标签,如: <div>欢迎访问【宜配屋www...

PHP实现股票趋势图和柱形图

基于强大的pchart类库。 <?php /* * 股票趋势图和柱形图 * @author: Skiychan <developer@zzzzy.com&g...

PHP5.2中PDO的简单使用方法

本文实例讲述了PHP5.2中PDO的简单使用方法。分享给大家供大家参考,具体如下: 一、PDO配置 1、确保PHP版本为5.2.5以上 2、在php.ini中找到Dynamic Exte...

php实现encode64编码类实例

本文实例讲述了php实现encode64编码类。分享给大家供大家参考。具体如下: encode64可以获得最短的由26个英文大小写字母数字加上"-_"两个符号编码的数据, 这个个字串可以...