php 显示指定路径下的图片_php教程-查字典教程网
php 显示指定路径下的图片
php 显示指定路径下的图片
发布时间:2016-12-29 来源:查字典编辑
摘要:复制代码代码如下: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教程学习
    编程开发子分类