手机
当前位置:查字典教程网 >编程开发 >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生成圆角图片的方法

php筛选不存在的图片资源

php实现图片转换成ASCII码的方法

PHP教程:实现的将图片转换为TXT

php生成年月日下载列表的方法

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

php从文件夹随机读取文件的方法

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

php计算到指定日期还有多少天的方法

精品推荐
分类导航