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 字符串函数收集

1查找字符位置函数: strpos($str,search,[int]):查找search在$str中的第一次位置从int开始; stripos($str,search,[int]):函...

php使用ftp实现文件上传与下载功能

本文实例为大家分享了php ftp文件上传与下载的具体代码,供大家参考,具体内容如下 ftp文件上传 php自带有ftp操作的函数包,一个比较简单实现的ftp文件上传操作可以通过以下几个...

php短域名转换为实际域名函数

复制代码 代码如下: $url = "http://sinaurl.cn/hbdsU5"; echo unshorten($url); function unshorten($url)...

laravel创建类似ThinPHP中functions.php的全局函数

前言 一直觉得ThinPHP中的公共函数是一个很好的设计,因为我们只需要在functions.php中对共用的函数进行封装,然后就可以在全局直接进行调用了。其实Laravel中也有类似的...

php知道与问问的采集插件代码

最近发现知道和问问小偷的版本越来越多了!! 看过一个百度小偷的网站也达到了pr6。收录十万多!! 在经过 荐礼啦 四十天的实践之后 发现百度对这个确实挺友好的。 从网站访问来看 很多也是...