当前位置: 首页 > 图文教程 > 网络编程 > PHP > php 显示指定路径下的图片

PHP
IIS+mysql+php学习
PEAR MDB 数据库抽象层 ?? 一次编写?随处运行
数据库设计技巧(二)
数据库设计技巧(三)
PHP中通过ADO调用Access数据库
从 MySQL 导入导出大量数据的程序实现方法
MySQL中修改密码及访问限制设置详解
数据库设计范式
MySQL 查询中的分页思路的优化
Adodb 官方介绍
PHP中 ADOdb 类库介绍(二)
PHP中 ADOdb 类库介绍(一)
MySQL中各种字段的取值范围
数据库设计技巧(一)
为数据库建立索引(一)
为数据库建立索引(二)
用 PHP 实现 XML 备份 Mysql 数据库
mysql常见出错代码
浅谈php+mysql身份验证的方法
apache服务器配置全攻略

PHP 中的 php 显示指定路径下的图片


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-10   浏览: 91 ::
收藏到网摘: n/a

给一个路径,得到她下面的图片,并显示出来的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;
}