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 可阅读随机字符串代码

复制代码 代码如下: /************** *@length - length of random string (must be a multiple of 2) *****...

phpMyadmin 用户权限中英对照

数据: SELECT:允许读取数据。 INSERT:允许插入和替换数据。 UPDATA:允许更改数据。 DELETE:允许删除数据。 FILE:允许从文件中导入数据以及将数据导出至文件。...

PHP限制页面只能在微信自带浏览器访问的代码

为了防止自己辛辛苦苦做的webapp被人copy,我们都想限制程序只能在微信里面浏览,虽然下面实现了这个功能,单都是小菜,没什么技术含量,懂代码的伪造下就破了。下面是PHP限制页面只能在...

PHP ADODB实现分页功能简单示例

PHP ADODB实现分页功能简单示例

本文实例讲述了PHP ADODB实现分页功能。分享给大家供大家参考,具体如下: 一、代码 adodb.inc.php可从官方网站http://adodb.sourceforge.net/...

PHP中使用虚代理实现延迟加载技术

话说这货是从 Martin 大神的《企业应用架构模式》中学到的,辅助 PHP 动态语言的特性,可以比 Java 轻松很多的实现延迟加载——通过一个虚代理占位符。唯一的缺陷,是只能代理对象...