关于下载文件失败的问题
各位老师,大家好,我在网上找到以下关于读取服务器上某文件夹上所有文件的列表,点击可以下载的程序,但我发现有些文件可以下载(因为是程序读取文件名的,因此不存在没此文件的可能出现),但有些不可以,但改过名后就可以,请帮查找原因,谢谢。<%
'****************************************************
' 程序制作:陈马勇 联系QQ:76087899
'****************************************************
<html>
<head>
<title>在线投稿管理</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<style type=text/css>
table { border:0px; }
td { font:normal 12px 宋体;}
img { vertical-align:bottom; border:0px; }
a { font:normal 12px 宋体; color:#000000; text-decoration:none; }
a:hover { color:#428EFF;text-decoration:underline; }
.sec_menu { border-left:1px solid white; border-right:1px solid white; border-bottom:1px solid white; overflow:hidden; background:#D6DFF7; }
.menu_title { }
.menu_title span { position:relative; top:0px; left:8px; color:#000000; font-weight:bold; }
.menu_title2 { }
.menu_title2 span { position:relative; top:0px; left:8px; color:#999999; font-weight:bold; }
</style>
</head>
<body text="#000000" LEFTMARGIN="0" TOPMARGIN="0" link="#D2E4FC" vlink="#0066FF" alink="#00CCFF">
<TABLE WIDTH="100%" BORDER="0" CELLPADDING="2" CELLSPACING="0" CLASS="HeaderTdStyle" >
<TR> <FORM NAME="form1" METHOD="post" ACTION=""></FORM></TR>
</TABLE>
<%
if request("path")<>"" then
path=request("path")
else
path="../pass"
end if
dim pagesize, page, filenum, pagenum
pagesize=20
page=request.querystring("page")
if page="" or not isnumeric(page) then
page=1
else
page=int(page)
end if
%><table cellpadding="2" cellspacing="1" border="0" width="54%" class="border" style="table-layout:fixed;word-break:break-all" BGCOLOR="#799AE1" align="center">
<tr BGCOLOR="#D2E4FC">
<td width="37" height=26 CLASS="title" align="center">
<p align="center">类型</td>
<td CLASS="title" BGCOLOR="#D2E4FC" WIDTH="163" height="26" align="center">
<p align="center">文件名 (右键下载)</td>
<td width="67" CLASS="title" height="26" align="center">
<p align="center">大小</td>
<td width="141" CLASS="title" height="26" align="center">
<p align="center">提交时间</td>
<td width="141" CLASS="title" height="26" align="center">
<p align="center">备注</td>
<td width="96" CLASS="title" height="26" align="center">
<p align="center">文件删除</td>
<%Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
if request("filename")<>"" then
if objFSO.fileExists(Server.MapPath(""&path&"\"&request("filename"))) then
objFSO.DeleteFile(Server.MapPath(""&path&"\"&request("filename")))
else
response.write "未找到"&path&request("filename")
end if
end if
on error resume next
Set uploadFolder=objFSO.GetFolder(Server.MapPath(""&path&"\"))
Set uploadFiles=uploadFolder.Files
filenum=uploadfiles.count
pagenum=int(filenum/pagesize)
if filenum mod pagesize>0 then
pagenum=pagenum+1
end if
if page> pagenum then
page=1
end if
i=0
For Each Upname In uploadFiles
i=i+1
if i>(page-1)*pagesize and i<=page*pagesize then
upfilename=upname.name
response.write "<tr><td height=24 BGCOLOR=#D2E4FC>"&i&"</td>"
response.write "<td BGCOLOR=#eeeeee><a href="""&path&"/"&upfilename&""" target=_blank>"&upfilename&"</a></td>"
response.write "<td BGCOLOR=#eeeeee>"& upname.size &" B </td>"
response.write "<td BGCOLOR=#eeeeee>"& upname.datelastmodified &"</td>"
if upname.description="" then
response.write "<td BGCOLOR=#eeeeee>" ''"</td>"
else
response.write "<td BGCOLOR=#eeeeee>"& upname.description &"</td>"
end if
if session("flag")>1 then
response.write "<td BGCOLOR=#eeeeee>在线提交</td>"
else
if session("sc")>=9 then
response.write "<td BGCOLOR=#eeeeee><a href='?filename="&upname.name&"&path="&request("path")&"'>---【删除】---</a></td>"
end if
end if
elseif i>page*pagesize then
exit for
end if
next
set uploadFolder=nothing
set uploadFiles=nothing
%> </tr> <tr> <td colspan=5 align=center height=25 BGCOLOR="#eeeeee" width="645">
<p align="right"><%
if page>1 then
response.write "<a href=?page=1&path="&request("path")&">首页</a> <a href=?page="& page-1 &"&path="&request("path")&">上一页</a> "
else
response.write "首页 上一页 "
end if
if page<i/pagesize then
response.write "<a href=?page="& page+1 &"&path="&request("path")&">下一页</a> <a href=?page="& pagenum &"&path="&request("path")&">尾页</a>"
else
response.write "下一页 尾页"
end if
response.write " 共 "&filenum&" 个文件 "
%> </td></tr>
<tr>
<td colspan=5 align=center height=25 BGCOLOR="#eeeeee" width="645">
</a>
</td>
</tr>
</table>
</body>
</html>