首页 > 资讯列表 > 编程/数据库 >> PHP

php 显示指定路径下的图片

PHP 2014-12-09 04:48:04 转载来源: 网络整理/侵权必删

本文为大家提供的是一个php实现的可以用来显示指定路经下的图片示例代码:给一个路径,得到她下面的图片,并显示出来的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:50p

本文为大家提供的是一个php实现的可以用来显示指定路经下的图片示例代码:给一个路径,得到她下面的图片,并显示出来的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 显示 指定 路径 图片


声明:本文内容来源自网络,文字、图片等素材版权属于原作者,平台转载素材出于传递更多信息,文章内容仅供参考与学习,切勿作为商业目的使用。如果侵害了您的合法权益,请您及时与我们联系,我们会在第一时间进行处理!我们尊重版权,也致力于保护版权,站搜网感谢您的分享!

站长搜索

http://www.adminso.com

Copyright @ 2007~2024 All Rights Reserved.

Powered By 站长搜索

打开手机扫描上面的二维码打开手机版


使用手机软件扫描微信二维码

关注我们可获取更多热点资讯

站长搜索目录系统技术支持