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排序算法之基数排序(Radix Sort)实例详解

本文实例讲述了PHP排序算法之基数排序(Radix Sort)。分享给大家供大家参考,具体如下: 基数排序在《大话数据结构》中并未讲到,但是为了凑齐八大排序算法,我自己通过网络学习了这个...

使用PHP求两个文件的相对路径

复制代码 代码如下:function compare($ph1,$ph2){    $ret = '';    $_f1Arr...

php操作excel文件 基于phpexcel

php操作excel文件 基于phpexcel

所以工作的第一步就是要将数据从excel中取出来。这里我使用到了一个开源php处理excel类:phpexcel. 该项目的详细信息 http://phpexcel.codeplex.c...

php获取通过http协议post提交过来xml数据及解析xml

php 如何获取请求的xml数据,对方通过http协议post提交过来xml数据,php如何获取到这些数据呢?复制代码 代码如下: <?php $xml_data ='<AA...

PHP实现数据四舍五入的方法小结【4种方法】

本文实例总结了PHP实现数据四舍五入的方法。分享给大家供大家参考,具体如下: 在PHP开发中,有时候我们会遇到将数据进行四舍五入的运算情况,本文分享了用PHP实现数据四舍五入的4种方法。...