php 显示指定路径下的图片

yipeiwu_com5年前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;
}

相关文章

奇怪的PHP引用效率问题分析

函数如下: 复制代码 代码如下: function update_timelist(&$arr,$timestamp,$threshold){ $timequeue = &$arr['t...

php使用Jpgraph创建柱状图展示年度收支表效果示例

php使用Jpgraph创建柱状图展示年度收支表效果示例

本文实例讲述了php使用Jpgraph创建柱状图展示年度收支表效果。分享给大家供大家参考,具体如下: 应用GD2库可以创建各式各样的图像,但是制作复杂的统计图形,仅通过GD2函数库来实现...

PHP结合Ueditor并修改图片上传路径

PHP结合Ueditor并修改图片上传路径

前言 在使用UEditor编辑器时,一般我们都是需要修改默认的图片上传路径的,下面是我整理好的修改位置和方法供大家参考。 操作 Ueditor PHP版本本身自带了一套上传程序,我们...

php实现简易聊天室应用代码

php实现简易聊天室应用代码

核心逻辑 在定义应用程序的核心功能之前,先来看一看聊天应用程序的基本外观,如以下截图所示: 通过聊天窗口底部的输入框输入聊天文本。点击Send按钮,就开始执行函数set_chat_ms...

php 抽象类的简单应用

All right, 父类postParent定义为抽象,规定子类必须重新实现 buildHTML()方法,这个方法并没有花括号,如果有不管有没有内容都会报错的。 现在越看越觉得这代码完...