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

PHP
php下载远程文件类--支持断点续传 (1)
方便实用的PHP生成静态页面类
PHP和Java强强联合 集成开发详解
实现Web 2.0 需借助开源技术力量
PHP实例:PHP上传自动生成缩略图及水印类
PHP技术:txtSQL安装手册中文版
利用PHP+JavaScript打造AJAX搜索窗
PHP利用cookie做的投票程序
PHP教程:用PHP程序对网页表单的处理
PHP应用:PHP在linxu下的安装与配置
PHP实例:PHP安全编程之加密功能
PHP技巧:关于cookie和session的分析
PHP入门:PHP网站开发中常见问题汇总
PHP教程:实现网站的无限分类
PHP技巧:用PHP控制您的浏览器cache
学习掌握动态网页PHP的编程语句
web开发中PHP+MySQL分页显示示例分析
PHP安装十大经典问题
BluePage通用分页类助开发者提高开发效率
实现强大的翻页跳转功能

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


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