DANHAND

图书馆系统

交流群: 208922879
技术QQ: 1379962711

lib分类

推荐lib

循环输出文件夹下的图片

当前文件夹下显示图片:

<%
dim fso,objFolder,objFiles
dim filelist
Set fso=Server.CreateObject("Scripting.FileSystemObject")

'on error resume next
Set objFolder=fso.GetFolder(server.MapPath("."))
Set objFiles=objFolder.Files
'循环输出文件夹path下的文件的文件名
For each objFile in objFiles
If getExt(objFile.name)="gif" or getExt(objFile.name)="jpg" or getExt(objFile.name)="jpeg" Then
filelist = filelist&"<div><a href='"&objFile.name&"' target=""_blank""><img src="""&objFile.name&""" width=""480"" height=""320"" border=""0"" align=""middle""></a><br>&nbsp;&nbsp;&nbsp;</div>"
End If
Next

'释放对象
Set objFolder=nothing
Set fso=nothing

'获取文件类型
Function getExt(str)
getExt = Lcase(Right(str,Len(str)-InstrRev(str,".")))
End Function
%>
说明文字
<p>
<%=filelist%>
</P>
 

---------------------------------------------------------------------------------------------------------------------

以下为子文件下的输出方法(带文件名)(以help为例):

<%
dim fso,objFolder,objFiles
dim filelist
Set fso=Server.CreateObject("Scripting.FileSystemObject")

'on error resume next
Set objFolder=fso.GetFolder(server.MapPath("./help"))
Set objFiles=objFolder.Files
'循环输出文件夹path下的文件的文件名
For each objFile in objFiles
If getExt(objFile.name)="gif" or getExt(objFile.name)="jpg" or getExt(objFile.name)="jpeg" Then
filelist = filelist&"<div><a href='"&objFile.name&"' target=""_blank""><img src=""help/"&objFile.name&""" width=""480"" height=""320"" border=""0"" align=""middle""></a><br>"&objFile.name&"&nbsp;&nbsp;&nbsp;</div>"
End If
Next

'释放对象
Set objFolder=nothing
Set fso=nothing

'获取文件类型
Function getExt(str)
getExt = Lcase(Right(str,Len(str)-InstrRev(str,".")))
End Function
%>
说明文字
<p>
<%=filelist%>
</P>