请教,为何无法下载大文件?给分

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile url(url是文件源)
ContentType = "application/octet-stream
Response.AddHeader "Content-Disposition", "attachment; filename=" & flName
Response.AddHeader "Content-Length", flsize
Response.ContentType = ContentType
Response.BinaryWrite objStream.Read
Response.Flush
response.Clear()
objStream.Close
Set objStream = Nothing
程序大概是这样,只能下载几十M的文件,不能下载200多M的文件,而且内存占用率狂长?多多帮忙!
---------------------------------------------------------------

这种方式把读取文件以字符流形式读取到对象中,然后再进行下载,
对象长时间占用服务器资源

大文件最好还是使用ftp方式

:_)
---------------------------------------------------------------

直接把你的大文件目录设成一个ftp服务器然后用ftp://IP/文件名的方式下载。
---------------------------------------------------------------

ftp: 存放提供下载的文件
http:存储文件路径(ftp地址),通过程序获得文件的路径(ftp地址),转向到地址

:_)
---------------------------------------------------------------

1   
2call downloadFile(url)   
 1   
 2Function downloadFile(strFile)   
 3' make sure you are on the latest MDAC version for this to work   
 4' -------------------------------------------------------------   
 5' get full path of specified file   
 6strFilename = server.MapPath(strFile)   
 7' clear the buffer   
 8Response.Buffer = True   
 9Response.Clear   
10' create stream   
11Set s = Server.CreateObject("ADODB.Stream")   
12s.Open   
13' Set as binary   
14s.Type = 1   
15' load in the file   
16on error resume next   
17' check the file exists   
18Set fso = Server.CreateObject("Scripting.FileSystemObject")   
19if not fso.FileExists(strFilename) then   
20Response.Write("

<h1>Error:</h1>

1" & strFilename & " does not exist

<p>")
Response.End
end if
' get length of file
Set f = fso.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
if err then
Response.Write("<h1>Error: </h1>" &amp; err.Description &amp; "<p>")
Response.End
end if
' send the headers to the users browser
Response.AddHeader "Content-Disposition", "attachment; filename=" &amp; f.name
Response.AddHeader "Content-Length", intFilelength
Response.ContentType = "application/save"
' output the file to the browser
Response.BinaryWrite s.Read
Response.Flush
' tidy up
s.Close
Set s = Nothing
End Function

Published At
Categories with Web编程
Tagged with
comments powered by Disqus