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

PHP
AJAX在PHP中的简单使用
vim下高亮显示php代码
用 PHP 使 Web 数据分析进入更高境界
用Apache与MySQL整合实现基本身份认证
通用PHP动态生成静态HTML网页的代码
自己轻松修复Discuz!数据库技巧
PHP在Web开发领域的优势在哪?
php4和php5单态模式(Singleton Pattern)写法
使用Xdebug优化你的php程序
PHP学习入门的一些基础知识
关于正则表达式学习
浅谈PHP开发团队的管理之道
传奇的诞生,PHP三位创始人简介
利用PHP制作简单的内容采集器
PHP精确到每一秒钟的在线人数显示代码
一些PHP学习过程中的心得和经验
WINDOWS服务器安装多套PHP的另类解决方案
让你的PHP引擎全速运转的三个简单绝招
大型系统上PHP令人不爽的九大原因
php的计数器程序

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


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