php 显示指定路径下的图片

yipeiwu_com5年前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 INT类型在内存中占字节详解

PHP INT类型在内存中占字节详解

本教程将介绍输出INT类型在内存中占多少个字节 新建一个333.php,如图所示: 添加php的界定符(<?php?>),如图所示: 声明PHP与浏览器交...

如何在PHP中使用正则表达式进行查找替换

1. preg_match — 执行一个正则表达式匹配int preg_match ( string $pattern , string $subject [, array &$matc...

全面解析PHP验证码的实现原理 附php验证码小案例

拓展 我们需要开启gd拓展,可以使用下面的代码来查看是否开启gd拓展。 <?php echo "Hello World!!!!"; echo phpinfo();...

php 生成短网址原理及代码

php 生成短网址 原理: 1.将原网址做crc32校验,得到校验码。 2.使用sprintf('%u') 将校验码转为无符号数字。 3.对无符号数字进行求余62操作(大小写字母+数字等...

PHP最新抖音视频解析接口源码

<?php function GetVideos($url) {     $ch = curl_init();...