Home  >  Article  >  Backend Development  >  php displays images under the specified path_PHP tutorial

php displays images under the specified path_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:43:291125browse

复制代码 代码如下:

function getAllDirAndFile($path)
{
if(is_file($path))
{
if(isImage($path))
{
$str="";
$str.='';
$str.="";
$path=iconv("gb2312","utf-8",$path);
$str.="";
$str.="";
$str.="
".$path."
";
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;
}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/320734.htmlTechArticle复制代码 代码如下: function getAllDirAndFile($path) { if(is_file($path)) { if(isImage($path)) { $str=""; $str.='table style="border:solid 1px blue;" width="95%"'; $str.="tr...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn