网络编程 
首页 > 网络编程 > 浏览文章

php 显示指定路径下的图片

(编辑:jimmy 日期: 2024/9/25 浏览:3 次 )
复制代码 代码如下:
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="/UploadFiles/2021-04-02/.$path.">$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 pack与unpack 摸板字符字符含义
下一篇:dedecms 批量提取第一张图片最为缩略图的代码(文章+软件)
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网 SiteMap