源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

php 显示指定路径下的图片

  • 时间:2020-07-04 03:52 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:php 显示指定路径下的图片
[u]复制代码[/u] 代码如下:
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; }
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部