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

PHP
WASP使用方法简介(3)
MySQL服务器的启动与停止
PHP中如何在输出内容后再输出头信息?
在phpMyAdmin使用用户口令登陆
解决MySQL 4.1乱码问题
PHP中操作MySQL需要注意的问题
distinct去掉mysql中重复值
MySQL权威指南读书笔记(一)
MySQL权威指南读书笔记(二)
MySQL权威指南读书笔记(三)
Mysql权威指南读书笔记(四)
MYSQL权威指南读书笔记
MySQL 的外键与参照完整性: Part 1
在PHP5中使用DOM控制XML(1)
在PHP5中使用DOM控制XML(2)
php数据库备份参考
厂商合推SCA和SDO规范 增强SOA技术合作
MySQL 4.1的编码问题
SELECT 的使用详解
Linux网络备份MYSQL

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-10   浏览: 88 ::
收藏到网摘: 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;
}