php 顯示指定路徑下的圖片
更新時(shí)間:2009年10月29日 22:13:48 作者:
給一個(gè)路徑,得到她下面的圖片,并顯示出來(lái)的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常見(jiàn)路徑用法分析
- php上傳圖片到指定位置路徑保存到數(shù)據(jù)庫(kù)的具體實(shí)現(xiàn)
- PHP pathinfo()獲得文件的路徑、名稱(chēng)等信息說(shuō)明
- PHP中require和include路徑問(wèn)題詳解
- php獲取url字符串截取路徑的文件名和擴(kuò)展名的函數(shù)
- PHP爆絕對(duì)路徑方法收集整理
- 談?wù)凱HP中相對(duì)路徑的問(wèn)題與絕對(duì)路徑的使用
相關(guān)文章
PHP實(shí)現(xiàn)防重復(fù)提交(防抖)的方法總結(jié)
當(dāng)涉及到處理表單提交或用戶點(diǎn)擊按鈕等操作時(shí),防抖(Debounce)是一種重要的技術(shù),它可以有效地防止不必要的重復(fù)操作,本文為大家整理了 PHP 中防抖的多種實(shí)現(xiàn)方法,需要的可以參考下2023-09-09
php完全過(guò)濾HTML,JS,CSS等標(biāo)簽
全是正則過(guò)濾HTML標(biāo)簽,但是今天自己拿來(lái)用都不好用了.原因??就是標(biāo)簽轉(zhuǎn)義了.2009-01-01
PHP 字符串加密函數(shù)(在指定時(shí)間內(nèi)加密還原字符串,超時(shí)無(wú)法還原)
最近, 從discuz里面發(fā)現(xiàn)了一個(gè)很牛的加密解密函數(shù)。此函數(shù)的厲害之處在于可以在指定時(shí)間內(nèi)加密還原字符串,超時(shí)無(wú)法還原.2010-04-04

