网站建设资讯

NEWS

网站建设资讯

asp强制下载函数

ASP 代码:
<%
========调用========

创新互联专注于鸡泽企业网站建设,成都响应式网站建设公司,商城网站建设。鸡泽网站建设公司,为鸡泽等地区提供建站服务。全流程定制网站设计,专业设计,全程项目跟踪,创新互联专业和态度为您提供的服务


downloadFile("test/test.mdb")

---Down File---
Function downloadFile(strFile)
get full path of specified file
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("

Error:

" & strFilename & " does not exist

")
Response.End
end if
Set f = fso.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
if err then
Response.Write("

Error:

" & err.Description & "

")
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
%>


分享标题:asp强制下载函数
分享路径:http://cdweb.net/article/sshcdo.html