我在网上搜到一段代码,是用asp实现直接下载的,但有问题,能帮我看看吗?
<%
'定义所有需要使用的变量
Dim strFilename,S,Fso,F,intFilelength
Filename =Server.MapPath(Trim(Request("File")))
Response.Buffer = True
Response.Clear
Set S = Server.CreateObject("ADODB.Stream")
S.Open
S.Type
=
1
On
Error
Resume
Next
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
strFilename=Filename
If Not Fso.FileExists(strFilename) Then
Response.Write("<h1>Error:</h1>"&strFilename&"你要下载的文件不存在!<p>")
Response.End
End
If
Set F = Fso.GetFile(strFilename)
intFilelength = F.Size '获取文件大小
S.LoadFromFile(strFilename)
If Err Then
Response.Write("<h1>Error: </h1>Unknown Error!<p>")
Response.End
End If
Response.AddHeader "Content-Disposition","attachment;filename="&F.name
Response.AddHeader "Content-Length",intFilelength
Response.CharSet = "GB2312"
Response.ContentType = "application/octet-stream"
Response.BinaryWrite
S.Read
Response.Flush
S.Close
Set S = Nothing
%>