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

PHP
在PHP中以root身份运行外部命令
PHP编程常用技巧四则
实例学习PHP之投票程序篇
PHP中的加密功能
PHP VS ASP
PHP生成动态WAP页面
PHP中for循环语句的几种变型
PHP5.0对象模型探索之对象串行化
PHP5.0对象模型探索之重载
浅议PHP程序开发中的模板选择
用PHP写的身份证验证程序
PHP.MVC的模板标签系统之初识PHP.MVC
PHP程序加速探索之代码优化
PHP程序加速探索之压缩输出gzip
用PHP文件上传的具体思路及实现
使用PHP编写基于Web的文件管理系统
理解PHP中的MVC编程之控制器
PHP程序加速探索之缓存输出
让你的PHP引擎全速运转的三个绝招
PHP程序加速探索之加速工具软件

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


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