asp获取服务器一目录下的所有图片的文件名

asp获取服务器一目录下的所有图片的文件名,第1张

<%
'以下为修改内容
Const UploadDir="/picture/" '存放文件的目录
Const Up="/picture/" '存放文件的目录
Const MaxPerPage=30 '每页显示数量
const Webpage="时尚网页" '标题
'检查组件是否已经安装
Function IsObjInstalled(strClassString)
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = ServerCreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function
dim strFileName
dim totalPut,CurrentPage,TotalPages
dim TruePath,fso,theFolder,theFile,whichfile,thisfile,FileCount,TotleSize
strFileName=""
if request("page")<>"" then
currentPage=cint(request("page"))
else
currentPage=1
end if
TruePath=ServerMapPath(UploadDir)
If not IsObjInstalled("ScriptingFileSystemObject") Then
ResponseWrite "<b><font color=red>你的服务器不支持 FSO(ScriptingFileSystemObject)! 不能使用本功能</font></b>"
Else
set fso=CreateObject("ScriptingFileSystemObject")
if fsoFolderExists(TruePath)then
FileCount=0
TotleSize=0
Set theFolder=fsoGetFolder(TruePath)
For Each theFile In theFolderFiles
FileCount=FileCount+1
TotleSize=TotleSize+theFileSize
next
totalPut=FileCount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
showContent
showpage2 strFileName,totalput,MaxPerPage
responsewrite "<br><div align='center'>本页共显示 <b>" & FileCount-1 & "</b> 个,占用 <b>" & TotleSize\1024 & "</b> K</div>"
else
if (currentPage-1)MaxPerPage<totalPut then
showContent
showpage2 strFileName,totalput,MaxPerPage
responsewrite "<br><div align='center'>本页共显示 <b>" & FileCount-1 & "</b> 个,占用 <b>" & TotleSize\1024 & "</b> K</div>"
else
currentPage=1
showContent
showpage2 strFileName,totalput,MaxPerPage
responsewrite "<br><div align='center'>本页共显示 <b>" & FileCount-1 & "</b> 个,占用 <b>" & TotleSize\1024 & "</b> K</div><br><br>"
end if
end if
else
responsewrite "找不到文件夹!可能是配置有误!"
end if
end if
sub showContent()
dim c
FileCount=1
TotleSize=0
%>
<TABLE cellSpacing=5 cellPadding=5 border=0>
<TBODY>
<TR bgColor=#ffffff>
<% For Each theFile In theFolderFiles
c=c+1
if FileCount>MaxPerPage then
exit for
elseif c>MaxPerPage(CurrentPage-1) then %>
<TD align=middle width="138">
<img src=<%=(UploadDir & theFileName)%> border=0><br>
<%
dim str
str=""&(theFileName)&""
str1=str
str2=str
str=replace(str,"jpg","")
if instr(1,str,"/")>0 then
str=split(str,"/")
str1=str(0)
end if
%><%=str%>
</td>
<% if FileCount mod 5 =0 then%>
</TR>
<TR bgColor=#ffffff>
<%end if%>
<% FileCount=FileCount+1
TotleSize=TotleSize+theFileSize
end if
Next
%>
</tr></TBODY></table>
<%
end sub
sub showpage2(sfilename,totalnumber,maxperpage)
dim n, i,strTemp
if totalnumber mod maxperpage=0 then
n= totalnumber \ maxperpage
else
n= totalnumber \ maxperpage+1
end if
strTemp= "<TABLE cellSpacing=1 cellPadding=1 border=0 align='center'><TR bgColor=#ffffff><form name='showpages' method='Post' action='" & sfilename & "'><td align='center'>"
strTemp=strTemp & "共 <b>" & totalnumber & "</b> 个 "
if CurrentPage<2 then
strTemp=strTemp & "首页 上一页 "
else
strTemp=strTemp & "<a href='" & sfilename & "page=1'>首页</a> "
strTemp=strTemp & "<a href='" & sfilename & "page=" & (CurrentPage-1) & "'>上一页</a> "
end if
if n-currentpage<1 then
strTemp=strTemp & "下一页 尾页"
else
strTemp=strTemp & "<a href='" & sfilename & "page=" & (CurrentPage+1) & "'>下一页</a> "
strTemp=strTemp & "<a href='" & sfilename & "page=" & n & "'>尾页</a>"
end if
strTemp=strTemp & " 页次:<strong><font color=red>" & CurrentPage & "</font>/" & n & "</strong>页 "
strTemp=strTemp & " <b>" & maxperpage & "</b>" & "个/页"
strTemp=strTemp & " 转到:<select name='page' size='1' onchange='javascript:submit()'>"
for i = 1 to n
strTemp=strTemp & "<option value='" & i & "'"
if cint(CurrentPage)=cint(i) then strTemp=strTemp & " selected "
strTemp=strTemp & ">第" & i & "页</option>"
next
strTemp=strTemp & "</select>"
strTemp=strTemp & "</td></form></tr></table>"
responsewrite strTemp
end sub
%>


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/10934999.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-12
下一篇 2023-05-12

发表评论

登录后才能评论

评论列表(0条)

保存