php 顯示指定路徑下的圖片
更新時間:2009年10月29日 22:13:48 作者:
給一個路徑,得到她下面的圖片,并顯示出來的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;
}
相關(guān)文章
淺析php插件 Simple HTML DOM 用DOM方式處理HTML
本篇文章是對php插件Simple HTML DOM 用DOM方式處理HTML進行了詳細的分析介紹,需要的朋友參考下2013-07-07php 獲取今日、昨日、上周、本月的起始時間戳和結(jié)束時間戳的方法
php 獲取今日、昨日、上周、本月的起始時間戳和結(jié)束時間戳的方法,主要使用到了 php 的時間函數(shù) mktime,下面首先還是直奔主題以示例說明如何使用 mktime 獲取今日、昨日、上周、本月的起始時間戳和結(jié)束時間戳,然后在介紹一下 mktime 函數(shù)作用和用法2013-09-09Could not load type System.ServiceModel.Activation.HttpModul
本文章來詳細介紹關(guān)于Could not load type System.ServiceModel.Activation.HttpModule from assembly System.ServiceModel解決辦法,有需要的朋友可參考2012-12-12字符串長度函數(shù)strlen和mb_strlen的區(qū)別示例介紹
strlen和mb_strlen的區(qū)別,但是對于一些初學者來說,如果不看手冊,也許不太清楚其中的區(qū)別,下面與大家分享下兩者之間的區(qū)別2014-09-09