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微信支付接口开发程序讲解: 必要条件: appid //公众号后台开发者中心获得(和邮件内的一样)   mchid//邮件内获得  key//商户后台...

几个php应用技巧

1、关于PHP重定向1、关于PHP重定向 方法一:header("Location: index.php"); 方法二:echo "<scrīpt>win...

php基础学习之变量的使用

复制代码 代码如下: <?php //引用 $one="test"; two=&$one;//相当于传地址,两个变量指向一个地址 //动态变量 $one="######";...

PHP观察者模式实例分析【对比JS观察者模式】

本文实例讲述了PHP观察者模式。分享给大家供大家参考,具体如下: 1.用js实现观察者模式 <!DOCTYPE html> <html> <head&g...

php合并数组中相同元素的方法

本文实例讲述了php合并数组中相同元素的方法。分享给大家供大家参考。具体如下: 关于重复数组的删除我们都介绍过N种方法了,今天这个例子有点不同就是 删除数组中相同的元素,只保留一个相同元...