您的位置:首页 > 其它

文件下载函数

2006-11-20 01:36 375 查看
<%
Function downloadFile(strFile)
strFilename=server.MapPath(strFile)
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")
if not fso.FileExists(strFilename) then
Response.Write("<p>Error:" & strFilename & "Nohave..</p>")
Response.End
end if
Set f=fso.GetFile(strFilename)
intFilelength=f.size
s.LoadFromFile(strFilename)
if err then
Response.Write("Path Error.")
Response.End
end if
Response.AddHeader "Content-Disposition","attachment;filename=" & f.name
Response.AddHeader "Content-Length",intFilelength
Response.CharSet="UTF-8"
Response.ContentType="application/octet-stream"
Response.BinaryWrite s.Read
Response.Flush
s.Close
Set s=Nothing
End Function

Call downloadFile(f_path)
%>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: