使用ASP制作下载文件链接遇到的奇怪问题,求解决
主页homepage.html很简单,就两个下载链接,如下<html>
<body>
<!-- 路径+文件名.后缀 -->
<a href="userdownloading.asp?FileName=/download/1.mp3" >1</a><br><br>
<a href="userdownloading.asp?FileName=/download/2.mp3" >2</a><br><br>
</body>
</html>
然后ASP下载源文件userdownloading.asp如下
<%
Dim Stream
Dim Contents
Dim FileName
Dim FileExt
Const adTypeBinary = 1
FileName=Request.QueryString("FileName")
%>
<%
if FileName = "" Then
Response.Write "<html><body><center><font size=10 color=#ff3300>网站内部错误,下载文件名为空</font></center><script language=javascript>setTimeout('history.back()',1000);</script></body></html>"
Response.End
End If
%>
<!-- 不希望被下载的文件扩展名 -->
<%
FileExt = Mid(FileName, InStrRev(FileName,".") + 1)
Select Case UCase(FileExt) '把 FileExt 转变为大写
Case "ASP","MDB","HTML"
Response.Write "<html><body><font size=10 color=#ff3300>网站内部错误,文件被保护,禁止下载</font></center><script language=javascript>setTimeout('history.back()',1000);</script></body></html>"
Response.End
End Select
%>
<!-- 下载文件 -->
<%
name=Mid(FileName, InStrRev(FileName, "/")+1)
Response.Clear
Response.ContentType = "application/octet-stream"
Response.AddHeader "content-disposition","attachment; filename="&name
Set Stream = server.CreateObject("ADODB.Stream")
Stream.Type = adTypeBinary
Stream.Open
Stream.LoadFromFile Server.MapPath(FileName)
While Not Stream.EOS
Response.BinaryWrite Stream.Read(1024 * 64)
Wend
Stream.Close
Set Stream = Nothing
Response.Flush
Response.End
%>
我在网站根目录下的download文件夹里面放了两首歌 1.mp3 和 2.mp3 ,点击主页上的下载链接,发现只有 2 能下载,而1则显示如下图
我是一个自学的新手,理论不是特别扎实,希望高手解答我的问题,感激不敬
--------------------编程问答--------------------
补充:.NET技术 , ASP.NET