ASP实现文件直接下载的方法
gt;Error:”&strFilename&” does not exists!”)
Response.End
end if
‘ get length of file
Set f = fso.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
if err then
Response.Write(“
Error:
Unknown Error!”)
Response.End
end if
‘ send the headers to the users Browse
Response.AddHeader “Content-Disposition”,”attachment; filename=”&f.name
Response.AddHeader “Content-Length”,intFilelength
Response.CharSet = “UTF-8”
Response.ContentType = “application/octet-stream”
‘ output the file to the browser
Response.BinaryWrite s.Read
Response.Flush
‘ tidy up
s.Close
Set s = Nothing
End Function
用上面的方法比直接超链接文件地址安全的多,而且不会直接打开文件。
如果downloadFile的参数不对,可以自定义replace里面的内容,上面只是我服务器的规则。
SQL update select结合语句详解及应用 RPC服务器不可用的解决方法