function getAllDirAndFile($path)
{
if(is_file($path))
{
if(isImage($path))
{
$str="";
$str.='<table>';
$str.="<tr>";
$path=iconv("gb2312","utf-8",$path);
$str.="<td width=80%>"https://www.jb51.net/article/.$path."</td><td width=15%><img src="https://www.jb51.net/article/.$path."></td>";
$str.="</tr>";
$str.="</table>";
echo $str;
}
}
else
{
$resource=opendir($path);
while ($file=readdir($resource))
{
if($file!="." && $file!="..")
{
getAllDirAndFile($path."https://www.jb51.net/".$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.heiqu.com/fece7e9ce6368b3603ee9d3049e4026a.html