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

PHP
PHP学习宝典-第四章
PHP学习宝典-第五章
PHP学习宝典-第六章
PHP学习宝典-第六章(续篇)
PHP学习宝典-第七章
PHP学习宝典-第八章(一)
PHP学习宝典-第八章(二)
PHP学习宝典-第九章
php配置,链接access数据库
HTML 初学者指南(一)
HTML 初学者指南(二)
HTML 初学者指南(三)
HTML 初学者指南(四)
HTML 初学者指南(五)
HTML 初学者指南(六)
HTML 初学者指南(七)
HTML 初学者指南(八)
HTML 初学者指南(九)
HTML 初学者指南(十)
网页常用特效整理:初级篇

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


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