经理
业务
您现在的位置:首页 >> 网站设计 >> 内容

asp网站制作使用流输出文件下载

<%
' 下载文件
function downloadfile(fullpath)

downloadfile = false

dim strfilename, s, fso, f, intfilelength

set fso = server.createobject("scripting.filesystemobject")

if not fso.fileexists(fullpath) then


exit function

end if

set f = fso.getfile(fullpath)

'获取文件大小

intfilelength = f.size

set s = server.createobject("adodb.stream")

s.open

s.type = 1

s.loadfromfile(fullpath)

response.buffer = true

response.clear

'response.addheader "Content-Encoding","GB2312" ' 乱码的解决方案

'response.addheader "content-type","application/x-msdownload"

response.addheader "content-disposition","attachment;filename=" & f.name

response.addheader "content-length" ,intfilelength

response.contenttype = "application/octet-stream"

while not s.eos


response.binarywrite s.read(1024 * 64)


response.flush

wend

s.close

set s = nothing

downloadfile = true
end function
%>

 

  • 九维软件科技有限公司 © 2010 版权所有 All Rights Resverved 未经授权,禁止复制、转播本站信息,经授权的引用必须注明出自本站 。
    Email:deuv@163.com 电话:0513-85338199 苏ICP备10045045号