国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > ASP > 正文

如何在瀏覽文件夾下面瀏覽所有圖片

2024-05-04 11:05:08
字體:
供稿:網(wǎng)友
計算機(jī)是每個人生活中不可缺少的一部分,它給我們帶來了很多便利和樂趣,但是有一部分朋友不熟悉這些操作,例如如何在瀏覽文件夾下面瀏覽所有圖片,錯新技術(shù)頻道小編帶你了解!

<%
'+-----------------------------------+
'|?????變量設(shè)置
'+-----------------------------------+
cTitle?=???"所有上傳圖片(注:以下為圖片文件夾下面所有圖片,并非全部為有效圖片!)"???'名字
cPicType?=???"jpeg,jpg,gif,png,bmp"???'圖片類型???(使用","將圖片格式分開)
cHeight?=???120???'縮圖高度
cWidth?=???120???'縮圖寬度
cEachLineMax?=???5?'每行顯示圖片數(shù)
cEachPageMax?=???20???'每頁顯示圖片數(shù)目
pic_path="/uploadpic/"?'設(shè)定圖片所在路徑
'+-----------------------------------+
'|?????定義函數(shù)
'+-----------------------------------+
Function???getExt(name)
getExt???=???right(name,???3)
End???Function

Function???isPIC(fileName,???picType)
ext???=???getExt(fileName)
isPIC???=???False
typeList???=???split(picType,???",")
For???ii???=???LBound(typeList)???To???UBound(typeList)
If???UCase(ext)???=???UCase(typeList(ii))???Then
isPIC???=???True
Exit???For
End???If
Next
End???Function

Function???pageBar(page,???pageTotal)
response.Write???"[???上一頁???]?"
response.Write???"
<<???"
i???=???pageStart
Do???while???i???<???page
response.Write???"
["???&???i???&???"]?"
i???=???i???+???1
Loop
response.Write???"["???&???page???&???"]"
i???=???pageMiddle
Do???while???i???<=???pageEnd
response.Write???"
["???&???i???&???"]?"
i???=???i???+???1
Loop
response.Write???"...
["???&???pageTotal???&???"]"
response.Write???"???
>>"
response.Write???"[???
下一頁???]?共???"???&???pageTotal???&???"???color=red>???頁??當(dāng)前所在第???"???&???page???&???"???color=red>???頁???圖片數(shù)???:???"???&???picTotal???&???"???color=red>"
End???Function
'+-----------------------------------+
'|?????取圖片尺寸類
'+-----------------------------------+
Class???possible
??dim???aso
??Private???Sub???Class_Initialize
????set???aso=CreateObject("Adodb.Stream")
????aso.Mode=3???
????aso.Type=1???
????aso.Open???
??End???Sub
??Private???Sub???Class_Terminate
????set???aso=nothing
??End???Sub
??Private???Function???Bin2Str(Bin)
????Dim???K,???Str
????For???K=1???to???LenB(Bin)
??????clow=MidB(Bin,K,1)
??????if???ASCB(clow)<128???then
????????Str???=???Str???&???Chr(ASCB(clow))
??????else
????????K=K+1
????????if???K???<=???LenB(Bin)???then???Str???=???Str???&???Chr(ASCW(MidB(Bin,K,1)&clow))
??????end???if
????Next???
????Bin2Str???=???Str
??End???Function

??Private???Function???Num2Str(num,base,lens)
????dim???ret
????ret???=???""
????while(num>=base)
??????ret???=???(num???mod???base)???&???ret
??????num???=???(num???-???num???mod???base)/base
????wend
????Num2Str???=???right(string(lens,"0")???&???num???&???ret,lens)
??End???Function

??Private???Function???Str2Num(str,base)
????dim???ret
????ret???=???0
????for???k=1???to???len(str)
??????ret???=???ret???*base???+???cint(mid(str,k,1))
????next
????Str2Num=ret
??End???Function

??Private???Function???BinVal(bin)
????dim???ret
????ret???=???0
????for???k???=???lenb(bin)???to???1???step???-1
??????ret???=???ret???*256???+???ascb(midb(bin,k,1))
????next
????BinVal=ret
??End???Function

??Private???Function???BinVal2(bin)
????dim???ret
????ret???=???0
????for???k???=???1???to???lenb(bin)
??????ret???=???ret???*256???+???ascb(midb(bin,k,1))
????next
????BinVal2=ret
??End???Function

??Private???Function???getImageSize(filespec)???
????dim???ret(3)
????aso.LoadFromFile(filespec)
????bFlag=aso.read(3)
????select???case???hex(binVal(bFlag))
????case???"4E5089":
??????aso.read(15)
??????ret(0)="PNG"
??????ret(1)=BinVal2(aso.read(2))
??????aso.read(2)
??????ret(2)=BinVal2(aso.read(2))
????case???"464947":
??????aso.read(3)
??????ret(0)="GIF"
??????ret(1)=BinVal(aso.read(2))
??????ret(2)=BinVal(aso.read(2))
????case???"535746":
??????aso.read(5)
??????binData=aso.Read(1)
??????sConv=Num2Str(ascb(binData),2???,8)
??????nBits=Str2Num(left(sConv,5),2)
??????sConv=mid(sConv,6)
??????while(len(sConv)????????binData=aso.Read(1)
????????sConv=sConv&Num2Str(ascb(binData),2???,8)
??????wend
??????ret(0)="SWF"
??????ret(1)=int(abs(Str2Num(mid(sConv,1*nBits+1,nBits),2)-Str2Num(mid(sConv,0*nBits+1,nBits),2))/20)
??????ret(2)=int(abs(Str2Num(mid(sConv,3*nBits+1,nBits),2)-Str2Num(mid(sConv,2*nBits+1,nBits),2))/20)
????case???"FFD8FF":
??????do???
????????do:???p1=binVal(aso.Read(1)):???loop???while???p1=255???and???not???aso.EOS
????????if???p1>191???and???p1<196???then???exit???do???else???aso.read(binval2(aso.Read(2))-2)
????????do:p1=binVal(aso.Read(1)):loop???while???p1<255???and???not???aso.EOS
??????loop???while???true
??????aso.Read(3)
??????ret(0)="JPG"
??????ret(2)=binval2(aso.Read(2))
??????ret(1)=binval2(aso.Read(2))
????case???else:
??????if???left(Bin2Str(bFlag),2)="BM"???then
????????aso.Read(15)
????????ret(0)="BMP"
????????ret(1)=binval(aso.Read(4))
????????ret(2)=binval(aso.Read(4))
??????else
????????ret(0)=""
??????end???if
????end???select
????ret(3)="width="""???&???ret(1)???&"""???height="""???&???ret(2)???&""""
????getimagesize=ret
??End???Function?
Function???readX(pic_path)
??????Set???fso1???=???server.CreateObject("Scripting.FileSystemObject")
??????Set???f1???=???fso1.GetFile(pic_path)
??????ext=fso1.GetExtensionName("."&pic_path)
??????select???case???UCase(ext)
??????????case???"GIF","BMP","JPG","PNG":
????????arr=getImageSize(f1.path)
????????readX???=???arr(1)
??????????case???"swf"
????????arr=pp.getimagesize(f1.path)
????????readX???=???arr(1)
??????end???select
??????Set???f1=nothing
??????Set???fso1=nothing
??End???Function
??Function???readY(pic_path)
??????Set???fso1???=???server.CreateObject("Scripting.FileSystemObject")
??????Set???f1???=???fso1.GetFile(pic_path)
??????ext=fso1.GetExtensionName("."&pic_path)
??????select???case???UCase(ext)
??????????case???"GIF","BMP","JPG","PNG":
????????arr=getImageSize(f1.path)
????????readY???=???arr(2)
??????????case???"swf"
????????arr=pp.getimagesize(f1.path)
????????readY???=???arr(2)
??????end???select
??????Set???f1=nothing
??????Set???fso1=nothing
??End???Function
End???Class
'+-----------------------------------+
'|?????數(shù)據(jù)處理
'+-----------------------------------+
Dim???fileArray()
reDim???fileArray(0)
Set???fileObj?=???Server.CreateObject("Scripting.FileSystemObject")
Set???folderObj?=???fileObj.GetFolder(server.MapPath("."&pic_path))
i???=???0
For???Each???file???in???folderObj.Files
If???isPIC(file.Name,???cPicType)???Then
fileArray(i)???=???file.Name
i???=???i???+???1
reDim???Preserve???fileArray(i)
End???If?
Next
Set???FileObj?=???Nothing
Set???FolderObj?=???Nothing
picTotal???=???UBound(fileArray)
'+-----------------------------------+
'|?????分頁處理
'+-----------------------------------+
page???=???int(Request.QueryString("page"))
pageTotal???=???-(int(-(picTotal/cEachPageMax)))
If???page???=???Empty???or???page???<???0???Then???page???=???1
If???page???>???pageTotal???Then???page???=???pageTotal
offset???=???cEachPageMax???*???page
start???=???offset???-???cEachPageMax
If???start???<???0???Then???start???=???0
If???offset???>???picTotal???Then???offset???=???picTotal
pageStart???=???page???-???cEachPageMax
If???pageStart???<=???0???Then???pageStart???=???1
pageMiddle???=???page???+???1
pageEnd???=???pageMiddle???+???cEachPageMax
If???page???<=???cEachPageMax???Then???pageEnd???=???cEachPageMax???*???2
If???pageEnd???>???pageTotal???Then???pageEnd???=???pageTotal
'+-----------------------------------+
'|?????輸出部分
'+-----------------------------------+
%>




???type='text>



");
function???showPopupText(){
var???o=event.srcElement;
MouseX=event.x;
MouseY=event.y;
if(o.alt!=null???&&???o.alt!="")???{???o.pop=o.alt;o.alt=""???}
if(o.title!=null???&&???o.title!=""){???o.pop=o.title;o.title=""???}
if(o.pop)???{???o.pop=o.pop.replace("/n","
");???o.pop=o.pop.replace("/n","
");???}
if(o.pop!=sPop)???{
sPop=o.pop;
clearTimeout(curShow);
clearTimeout(tFadeOut);
clearTimeout(tFadeIn);
clearTimeout(tFadeWaiting);?
if(sPop==null???||???sPop=="")???{
popLayer.innerHTML="";
popLayer.style.filter="Alpha()";
popLayer.filters.Alpha.opacity=0;?
}???else???{
if(o.dyclass!=null)???popStyle=o.dyclass???
else???popStyle="cPopText";
curShow=setTimeout("showIt()",tPopWait);
}
}
}
function???showIt()???{
popLayer.className=popStyle;
popLayer.innerHTML='
??'+sPop+'??

';
popWidth=popLayer.clientWidth;
popHeight=popLayer.clientHeight;
if(MouseX+12+popWidth>document.body.clientWidth)???popLeftAdjust=-popWidth-24
else???popLeftAdjust=0;
if(MouseY+12+popHeight>document.body.clientHeight)???popTopAdjust=-popHeight-24
else???popTopAdjust=0;
popLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
popLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
popLayer.style.filter="Alpha(Opacity=0)";
fadeOut();
}
function???fadeOut(){
if(popLayer.filters.Alpha.opacitypopLayer.filters.Alpha.opacity+=showPopStep;
tFadeOut=setTimeout("fadeOut()",1);
}
}
document.onmouseover=showPopupText;





?


<%=cTitle%>



<%???pageBar???page,???pageTotal???%>





<%
'+-----------------------------------+
'|?????循環(huán)輸出圖片
'+-----------------------------------+
j???=???1
i???=???start
Set???pp???=???New???possible
Do???While???i???<???offset
thisPicPath???=???server.mappath("."&pic_path??&???fileArray(i))
x???=???pp.readX(thisPicPath)
y???=???pp.readY(thisPicPath)
If???x???>???cWidth???or???y???>???cHeight???Then
tWidth???=???x???/???cWidth???:???tHeight???=???y???/???cHeight
If???tWidth???>???tHeight???Then
w???=???cWidth
h???=???y???/???tWidth
Elseif???tWidth???<???tHeight???Then
h???=???cHeight
w???=???x???/???tHeight
Else
w???=???cWidth
h???=???cHeight
End???If
Else
w???=???x
h???=???y
End???If
If???j???>???cEachLineMax???Then
j???=???1
response.Write???""
End???If
response.Write???"??尺寸:"???&???x???&???"???×???"???&???y???&???"??"">"
j???=???j???+???1
i???=???i???+???1
Loop
Set???pp???=???Nothing
%>




<%???pageBar???page,???pageTotal???%>
???>


通過錯新技術(shù)頻道小編介紹的內(nèi)容,相信大家都有了一定的了解,想要了解更多的技術(shù)內(nèi)容,請繼續(xù)關(guān)注錯新技術(shù)頻道吧!

?

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 密山市| 宣汉县| 息烽县| 宝清县| 商丘市| 彝良县| 赤水市| 安宁市| 介休市| 芦山县| 太湖县| 三门峡市| 航空| 东乡| 兰西县| 五莲县| 广宁县| 诸暨市| 二连浩特市| 两当县| 黄浦区| 台安县| 浠水县| 民县| 南丹县| 岳池县| 廉江市| 屏东县| 合水县| 古丈县| 霍城县| 江西省| 光山县| 平罗县| 永安市| 卢氏县| 沁源县| 新安县| 焉耆| 措美县| 郓城县|