windows 2003(已解除200k限制) + IIS6 + KesionCMS8.0 GBK
由于工作需要,须上传较大的附件(10 - 50m)
URL:http://www.blueskyfund.cn/kesion/club/display.asp?id=238&page=1
无论是在论坛还是在文章系统,无论是在后台还是前台,都可以成功上传:swfupload程序提示成功上传,在ftp上也能看到完整的文件。
但如果上传的是较大的文件(例如10m),前台就无法下载。点击下载所得到的文件是0字节。
========================================================
解决方法:
下载系统的修改文件为
item/download.asp
找到代码
Sub downloadFile(strFile,FileOldName)
On error resume next
Server.ScriptTimeOut=999999
Dim S,fso,f,intFilelength,strFilename,DownFileName
strFilename = strFile
Response.Clear
Set s = Server.CreateObject("ADODB.Stream")
s.Open
s.Type = 1
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(strFilename) Then
Response.Write("<h1>错误: </h1><br>系统找不到指定文件")
Exit Sub
End If
Set f = fso.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
If err Then
Response.Write("<h1>错误: </h1>" & err.Description & "<p>")
Response.End
End If
Set fso=Nothing
Dim Data
Data=s.Read
s.Close
Set s=Nothing
If FileOldName="" Or IsNull(FileOldName) Then DownFileName=f.name Else DownFileName=FileOldName
If Response.IsClientConnected Then
Response.AddHeader "Content-Disposition", "attachment; filename=" & DownFileName
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"
Response.BinaryWrite Data
Response.Flush
End If
End Sub
修改为:
Sub downloadFile(strFile,FileOldName)
Dim fso,f,intFilelength,strFilename,DownFileName
Set fso = Server.CreateObject("Scripting.FileSystemObject")
If Not fso.FileExists(strFile) Then
Response.Write("<h1>错误: </h1><br>系统找不到指定文件")
Exit Sub
End If
Set f = fso.GetFile(strFile)
Set fso=Nothing
If KS.IsNul(FileOldName) Then DownFileName=f.name Else DownFileName=FileOldName
Dim Stream,offset,TotalSize,ChunkSize ,strChunk
Response.Buffer=False '将Response.Buffer设为否
Response.ContentType = "application/octet-stream"
response.AddHeader "Content-Disposition","attachment;filename=" & DownFileName
Set Stream = Server.CreateObject("ADODB.Stream")
Stream.type=1
Stream.Open
Stream.LoadFromFile strFile
offset = 0
ChunkSize = 2048*1024 'ChunkSize小于IIS配制文件中的AspBufferingLimit项所设置的大小
TotalSize = Stream.Size
while offset < TotalSize
if (TotalSize - offset < ChunkSize) then
ChunkSize = TotalSize-offset
end if
strChunk = Stream.Read(ChunkSize)
Response.BinaryWrite strChunk
offset = offset + ChunkSize
wend
Stream.Close
End Sub
如果是论坛里的下载附件,则修改
item/filedown.asp,修改方法和上面一样。