程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> ASP編程 >> 關於ASP編程 >> 用ADODB.Stream下載大文件無法下載的問題

用ADODB.Stream下載大文件無法下載的問題

編輯:關於ASP編程
 

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
option explicit
dim sFile, sRoot, sDir, sExt, objShell, objFSO, sMIME, objStream, strFilename, f, intFilelength

Response.Buffer = True
Response.Clear
sRoot = application("QRP_Data_Path")

sDir = Request("dir")

sFile = Request("file")

set objFSO = server.CreateObject("Scripting.FileSystemObject")
sExt = objFSO.GetExtensionName (sFile)
Set f = objFSO.GetFile(sRoot & sDir & sFile)
intFilelength = f.size

set f = nothing
set objFSO = nothing

Set objShell = Server.CreateObject("Wscript.Shell")
On Error Resume Next
sMIME = objShell.RegRead("HKEY_CLASSES_ROOT." & sExt & "Content Type")
On Error GoTo 0

if len(sMIME) = 0 then
sMIME = "application/octetstream"

end if
set objShell = nothing
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1

objStream.LoadFromFile sRoot & sDir & sFile

Response.AddHeader "Content-Disposition", "filename=" & sFile & ";"
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = sMIME
Response.BinaryWrite objStream.Read
Response.Flush
objStream.Close
Set objStream = Nothing
%>

 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved