加入收藏 | 设为首页 | 会员中心 | 我要投稿 聊城站长网 (https://www.0635zz.com/)- 智能语音交互、行业智能、AI应用、云计算、5G!
当前位置: 首页 > 站长学院 > Asp教程 > 正文

ASP运用流输出文件下载

发布时间:2023-07-29 14:52:16 所属栏目:Asp教程 来源:
导读:<%

&#39; 下载文件

function downloadfile(fullpath)

downloadfile = false

dim strfilename, s, fso, f, intfilelength

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

if
<%
 
' 下载文件
 
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
 
%>
 
 

(编辑:聊城站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章