<%
' 下載文件
function downloadfile(fullpath)
downloadfile = false
dim strfilename, s, fso, f, intfilelength
set fso = server.createobject("scripting.filesystemobject")
如果不是 fso.fileexists(fullpath) 那麼
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"
而非 s.eos
回應.binarywrite s.read(1024 * 64)
response.flush
wend
s.close
設定 s = Nothing
downloadfile = true
結束函數
%>