手机
当前位置:查字典教程网 >编程开发 >php教程 >php 显示指定路径下的图片
php 显示指定路径下的图片
摘要:复制代码代码如下:functiongetAllDirAndFile($path){if(is_file($path)){if(isImage...

复制代码 代码如下:

function getAllDirAndFile($path)

{

if(is_file($path))

{

if(isImage($path))

{

$str="";

$str.='<table width="95%">';

$str.="<tr>";

$path=iconv("gb2312","utf-8",$path);

$str.="<td width=80%>".$path."</td><td width=15%><img src=".$path."></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 显示指定路径下的图片】相关文章:

php简单实现多字节字符串翻转的方法

PHP SPL标准库中的常用函数介绍

php支持中文字符串分割的函数

php实现随机显示图片方法汇总

php函数重载的替代方法

php4的彩蛋

php实现修改新闻时删除图片的方法

分页显示Oracle数据库记录的类之二

php显示时间常用方法小结

PHP中显示格式化的用户输入

精品推荐
分类导航