<%
'==================================================
'函数名:fso
'作 用:Fso组件
'参 数:无
'==================================================
function fso(filename)
set fs=server.CreateObject ("scripting.filesystemobject")
set fsts=fs.opentextfile(server.mappath(filename),1)
body=fsts.readall
fso=body
end function
%>
listtype=request("listtype")
inputname=request("inputname")
select case listtype
case "pic"
strUpFileType="jpg|gif|bmp|png"
case "flash"
strUpFileType="swf"
case "media"
strUpFileType="wmv|asf|avi|mpg|ram|rm|ra"
case else
strUpFileType="all"
end select
n=1
foldername=request.QueryString("foldername")
url=Request.ServerVariables("SCRIPT_NAME")&"?listtype="&listtype&"&foldername="&foldername&"&"
if foldername=Empty then
foldernames=Server.MapPath("../"&webuppath)
else
foldernames=Server.MapPath("../"&webuppath&foldername)
end if
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder(foldernames)
for each theFolder in folder.SubFolders
if n=1 then response.write "<tr align=center>" & vbcrlf
'if FileCount mod 5=0 then response.write "<tr align=center>" & vbcrlf
response.write "<td><a href=?listtype="&listtype&"&inputname="&inputname&"&foldername="&theFolder.Name&"><img src=../images/folder.gif width=100 height=70 border=0 align=absmiddleon alt='文件夹大小:"&format(theFolder.Size)&"<br>修改时间:"&theFolder.DateLastModified&"'></a><br>"&theFolder.Name&"</td>" & vbcrlf
if n=5 then n=0:response.write "</tr>" & vbcrlf
n=n+1
next
For Each theFile In folder.Files
strFileType=lcase(mid(theFile.Name,instrrev(theFile.Name,".")+1))
if instr(strUpFileType,strFileType)>0 then
FileCount=FileCount+1
'TotalSize=TotalSize+theFile.Size
end if
next
total=FileCount
FileCount=0
if curpage<1 then
curpage=1
end if
if (curpage-1)*MaxPage>total then
if (total mod MaxPage)=0 then
curpage= total \ MaxPage
else
curpage= total \ MaxPage + 1
end if
end if
For Each theFile In folder.Files
c=c+1
if FileCount=maxpage then exit for
if c>MaxPage*(CurPage-1) then
'if n=1 then response.write "<tr align=center>" & vbcrlf
if FileCount mod 5=0 then response.write "<tr align=center>" & vbcrlf
strFileType=lcase(mid(theFile.Name,instrrev(theFile.Name,".")+1))
if instr(strUpFileType,strFileType)>0 then
call list()
FileCount=FileCount+1
else
call list()
FileCount=FileCount+1
end if
if n=5 then n=0':response.write "</tr>" & vbcrlf
n=n+1
'FileCount=FileCount+1
if FileCount mod 5=0 then response.write "</tr>" & vbcrlf
end if
Next
set fso=nothing
%>
</table></td>
</tr>
<tr>
<td height="20" align="center"><a href=<%=Request.ServerVariables("SCRIPT_NAME")%>?listtype=<%=listtype%>&foldername=>返回</a> <%showpage url,total,maxpage,curpage%></td>
</tr>
</table>
<%
Function format(fig)
If fig <1024 Then
format = fig&" B"
ElseIf fig < 1048576 Then
format = Round(fig / 1024.1) & " KB"
Else
format = Round((fig/1024)/1024.1) & " MB"
End If
End Function
sub list()
select case strFileType
case "jpg","gif","bmp","png"
response.write "<td><img src='../" &webuppath&foldername&"/"&theFile.Name& "' border='0' title='文件大小:"&format(theFile.Size)&"<br>修改时间:"&theFile.DateLastModified&"' style='width:100px;height:70px;CURSOR: hand;' onClick=""javascript:window.opener."&inputname&".value='../" &webuppath&foldername&"/"&theFile.Name& "';window.close();""><br><a href=../" &webuppath&foldername&"/"&theFile.Name& " target=_blank>"&theFile.Name&"</a></td>" & vbcrlf
case "swf"
response.write "<td><img src='../images/flash.gif' style='width:100px;height:70px;CURSOR: hand;' onClick=""javascript:window.opener."&inputname&".value='../" &webuppath&foldername&"/"&theFile.Name& "';window.close();"" border='0'><br><a href../=" &webuppath&foldername&"/"&theFile.Name& " target=_blank>"&theFile.Name&"</a></td>" & vbcrlf
case "wmv","avi","asf","mpg"
response.write "<td><img src='../images/media.gif' style='width:100px;height:70px;CURSOR: hand;' onClick=""javascript:window.opener."&inputname&".value='../" &webuppath&foldername&"/"&theFile.Name& "';window.close();"" border='0'><br><a href=../" &webuppath&foldername&"/"&theFile.Name& " target=_blank>"&theFile.Name&"</a></td>" & vbcrlf
case "rm","ra","ram"
response.write "<td><img src='../images/rm.gif' style='width:100px;height:70px;CURSOR: hand;' onClick=""javascript:window.opener."&inputname&".value='../" &webuppath&foldername&"/"&theFile.Name& "';window.close();"" border='0'><br><a href=../" &webuppath&foldername&"/"&theFile.Name& " target=_blank>"&theFile.Name&"</a></td>" & vbcrlf
case "rar"
response.write "<td><img src='../images/rar.gif' style='width:100px;height:70px;CURSOR: hand;' onClick=""javascript:window.opener."&inputname&".value='../" &webuppath&foldername&"/"&theFile.Name& "';window.close();"" border='0'><br><a href=../" &webuppath&foldername&"/"&theFile.Name& " target=_blank>"&theFile.Name&"</a></td>" & vbcrlf
case "zip"
response.write "<td><img src='../images/zip.gif' style='width:100px;height:70px;CURSOR: hand;' onClick=""javascript:window.opener."&inputname&".value='../" &webuppath&foldername&"/"&theFile.Name& "';window.close();"" border='0'><br><a href=../" &webuppath&foldername&"/"&theFile.Name& " target=_blank>"&theFile.Name&"</a></td>" & vbcrlf
case "exe"
response.write "<td><img src='../images/exe.gif' style='width:100px;height:70px;CURSOR: hand;' onClick=""javascript:window.opener."&inputname&".value='../" &webuppath&foldername&"/"&theFile.Name& "';window.close();"" border='0'><br><a href=../" &webuppath&foldername&"/"&theFile.Name& " target=_blank>"&theFile.Name&"</a></td>" & vbcrlf
case else
response.write "<td><img src='../images/other.gif' style='width:100px;height:70px;CURSOR: hand;' onClick=""javascript:window.opener."&inputname&".value='../" &webuppath&foldername&"/"&theFile.Name& "';window.close();"" border='0'><br><a href=../" &webuppath&foldername&"/"&theFile.Name& " target=_blank>"&theFile.Name&"</a></td>" & vbcrlf
end select
end sub
%>
</body>
</html>
Dim fso, f, f1, fc
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(server.MapPath("/zzz/"))
Set fc = f.Files
For Each f1 in fc
response.Write "<a href='#'>" & f1.name & "</a><BR>"
Next