vithink小文件自动实现文件浏览下载
程序员文章站
2022-05-03 13:23:08
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
</head>
<body>
<script src=http://www.mithink.com/js/top.js></script>
<table id="table16" cellspacing="0" cellpadding="0" width="765" border="0">
<tr>
<td valign="bottom" align="middle" colspan="2">
<table id="table21" cellspacing="0" cellpadding="0" width="765" align="center" border="0">
<tr>
<td ><%
set fso = createobject("scripting.filesystemobject")
hu = replace(server.mappath("index.asp"),"index.asp","") '本系统所在目录
set testfolder = fso.getfolder(hu)
generatetestinformation = generateallfolderinformation(testfolder)
function generateallfolderinformation(folder)
dim s, subfolders, subfolder, files, file, i
tmpstr = ""
set subfolders = folder.subfolders
if subfolders.count <> 0 then
i = 1
for each subfolder in subfolders
i = i + 1
tmpstr = tmpstr & generatefolderinformation(subfolder,i)
next
end if
response.write tmpstr & "</table><br>"
tmpstr = ""
set files = folder.files
tmpstr = tmpstr & "<table border=0 width=100% cellspacing=1 cellpadding=4 align='left' style='word-break: break-all'>"
tmpstr = tmpstr & ""
if not (folder.isrootfolder) then
tmpstr = tmpstr & ""
end if
tmpstr = tmpstr & ""
tmpstr = tmpstr & ""
if files.count <> 0 then
i = 1
for each file in files
i = i + 1
tmpstr = tmpstr & generatefileinformation(file,i)
next
end if
response.write tmpstr & "</table>"
end function
function urlencode(path)
urlencode = replace(server.urlencode(path),"\","/")
end function
function closefso
fso.close
set fso = nothing
end function
function generatefileinformation(file,i)
dim s, rowcolor
rowcolor = ""
if i mod 2 = 0 then rowcolor = "bgcolor=#9999dd"
if i mod 2 <> 0 then rowcolor = "bgcolor=#aaaaee"
s = "<tr><td "&rowcolor&" > " & file.name & "</td>"
s = s & "<td "&rowcolor&">" & formatnumber(file.size/1024 ,0) & " kb</td>"
s = s & "<td align=center "&rowcolor&">"
s = s & "<a href='" & file.name & "' > ↓</a></td></tr>"
generatefileinformation = s
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' 函数名称:generatefolderinformation()
' 功能说明:描述文件夹的当前状态
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function generatefolderinformation(folder,i)
dim s, rowcolor
rowcolor = ""
if i mod 2 = 0 then rowcolor = "bgcolor=#dddddd"
s = ""
generatefolderinformation = s
end function
%>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script src=http://www.mithink.com/js/bottom1.js></script>
</body>
</html>
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
</head>
<body>
<script src=http://www.mithink.com/js/top.js></script>
<table id="table16" cellspacing="0" cellpadding="0" width="765" border="0">
<tr>
<td valign="bottom" align="middle" colspan="2">
<table id="table21" cellspacing="0" cellpadding="0" width="765" align="center" border="0">
<tr>
<td ><%
set fso = createobject("scripting.filesystemobject")
hu = replace(server.mappath("index.asp"),"index.asp","") '本系统所在目录
set testfolder = fso.getfolder(hu)
generatetestinformation = generateallfolderinformation(testfolder)
function generateallfolderinformation(folder)
dim s, subfolders, subfolder, files, file, i
tmpstr = ""
set subfolders = folder.subfolders
if subfolders.count <> 0 then
i = 1
for each subfolder in subfolders
i = i + 1
tmpstr = tmpstr & generatefolderinformation(subfolder,i)
next
end if
response.write tmpstr & "</table><br>"
tmpstr = ""
set files = folder.files
tmpstr = tmpstr & "<table border=0 width=100% cellspacing=1 cellpadding=4 align='left' style='word-break: break-all'>"
tmpstr = tmpstr & ""
if not (folder.isrootfolder) then
tmpstr = tmpstr & ""
end if
tmpstr = tmpstr & ""
tmpstr = tmpstr & ""
if files.count <> 0 then
i = 1
for each file in files
i = i + 1
tmpstr = tmpstr & generatefileinformation(file,i)
next
end if
response.write tmpstr & "</table>"
end function
function urlencode(path)
urlencode = replace(server.urlencode(path),"\","/")
end function
function closefso
fso.close
set fso = nothing
end function
function generatefileinformation(file,i)
dim s, rowcolor
rowcolor = ""
if i mod 2 = 0 then rowcolor = "bgcolor=#9999dd"
if i mod 2 <> 0 then rowcolor = "bgcolor=#aaaaee"
s = "<tr><td "&rowcolor&" > " & file.name & "</td>"
s = s & "<td "&rowcolor&">" & formatnumber(file.size/1024 ,0) & " kb</td>"
s = s & "<td align=center "&rowcolor&">"
s = s & "<a href='" & file.name & "' > ↓</a></td></tr>"
generatefileinformation = s
end function
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' 函数名称:generatefolderinformation()
' 功能说明:描述文件夹的当前状态
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
function generatefolderinformation(folder,i)
dim s, rowcolor
rowcolor = ""
if i mod 2 = 0 then rowcolor = "bgcolor=#dddddd"
s = ""
generatefolderinformation = s
end function
%>
</td>
</tr>
</table>
</td>
</tr>
</table>
<script src=http://www.mithink.com/js/bottom1.js></script>
</body>
</html>
下一篇: 使用函数自动生成n层目录