php 顯示指定路徑下的圖片
更新時(shí)間:2009年10月29日 22:13:48 作者:
給一個(gè)路徑,得到她下面的圖片,并顯示出來的php代碼。
復(fù)制代碼 代碼如下:
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絕對(duì)路徑與相對(duì)路徑之間關(guān)系的的分析
- PHP獲取文件絕對(duì)路徑的代碼(上一級(jí)目錄)
- 查找php配置文件php.ini所在路徑的二種方法
- 解析centos中Apache、php、mysql 默認(rèn)安裝路徑
- thinkphp常見路徑用法分析
- php上傳圖片到指定位置路徑保存到數(shù)據(jù)庫(kù)的具體實(shí)現(xiàn)
- PHP pathinfo()獲得文件的路徑、名稱等信息說明
- PHP中require和include路徑問題詳解
- php獲取url字符串截取路徑的文件名和擴(kuò)展名的函數(shù)
- PHP爆絕對(duì)路徑方法收集整理
- 談?wù)凱HP中相對(duì)路徑的問題與絕對(duì)路徑的使用
相關(guān)文章
php基礎(chǔ)知識(shí):類與對(duì)象(1)
php基礎(chǔ)知識(shí):類與對(duì)象(1)...2006-12-12PHP快速排序算法實(shí)現(xiàn)的原理及代碼詳解
在本篇文章里小編給大家整理了關(guān)于PHP快速排序算法實(shí)現(xiàn)的原理及代碼相關(guān)知識(shí)點(diǎn),需要的朋友們跟著學(xué)習(xí)下。2019-04-04淺析php插件 Simple HTML DOM 用DOM方式處理HTML
本篇文章是對(duì)php插件Simple HTML DOM 用DOM方式處理HTML進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-07-07php 獲取今日、昨日、上周、本月的起始時(shí)間戳和結(jié)束時(shí)間戳的方法
php 獲取今日、昨日、上周、本月的起始時(shí)間戳和結(jié)束時(shí)間戳的方法,主要使用到了 php 的時(shí)間函數(shù) mktime,下面首先還是直奔主題以示例說明如何使用 mktime 獲取今日、昨日、上周、本月的起始時(shí)間戳和結(jié)束時(shí)間戳,然后在介紹一下 mktime 函數(shù)作用和用法2013-09-09Could not load type System.ServiceModel.Activation.HttpModul
本文章來詳細(xì)介紹關(guān)于Could not load type System.ServiceModel.Activation.HttpModule from assembly System.ServiceModel解決辦法,有需要的朋友可參考2012-12-12字符串長(zhǎng)度函數(shù)strlen和mb_strlen的區(qū)別示例介紹
strlen和mb_strlen的區(qū)別,但是對(duì)于一些初學(xué)者來說,如果不看手冊(cè),也許不太清楚其中的區(qū)別,下面與大家分享下兩者之間的區(qū)別2014-09-09