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

PHP
仅用PHP4 Session实现的迷你购物篮(一)
仅用PHP4 Session实现的迷你购物篮(二)
MySQL数据导入与导出之二
实例学习PHP之FastTemplate 模板篇
PHP4调用自己编写的COM组件
简单的页面缓冲技术(一)
简单的页面缓冲技术(二)
简单的页面缓冲技术(三)
用Socket发送电子邮件(一)
用Socket发送电子邮件(二)
PHP/MySQL 购物车
介绍几个array库的新函数
一个用PHP实现的UBB类!
免费主页管理程序2.3(一)
在Linux下安装显卡驱动程序
用PHP发送有附件的电子邮件
PHP的十个高级技巧(上)
PHP的十个高级技巧(中)
PHP的十个高级技巧(下)
实例学习PHP之投票程序篇(二)

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


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