在ASP中如何下载超过200M以上的视频文件

tvruuiqpl1314520 2008-01-14 10:26:00
在ASP中我通过下载函数下载,不能超过200M以上的视频文件,系统弹出来的信息框文件大小变为0K!2003系统下,修改了IIS下载限制,从原来的4M变200M以内,但大于200M的文件,就下载不了了。在本地给这个函数以固定的路径,较大的文件是可以下载的,以下是我调用的下载函数

<!--#include file="conn1.asp"-->
<%
dim AsfFile_No,sql,filename
AsfFile_No=request.QueryString("AsfFile_No")

set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from AsfFiles where AsfFile_No='"&AsfFile_No&"'"
rs.open sql,conn,3,3
filename=rs("AsfFile_Name")
call downloadFile(filename)
Function downloadFile(strFile)
strFilename = strFile
Response.Buffer = True
Response.Clear

Set s = Server.CreateObject("ADODB.Stream")
s.Open
s.Type = 1
on error resume next

Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(strFilename) then
Response.Write("<h1>Error:</h1>" & strFilename & "文件不存在!<p>")
Response.End
end if

Set f = fso.GetFile(strFilename)
sFilelength = f.size
s.LoadFromFile(strFilename)
if err then
Response.Write("<h1>Error: </h1>" & err.Description & "<p>")
Response.End
end if

Select Case lcase(Right(filename, 4))
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".txt"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End Select
Response.AddHeader "Content-Disposition", "attachment; filename=" & f.name
Response.AddHeader "Content-Length",sFilelength //在这个地方超过200M,文件大小变为0K
Response.CharSet = "UTF-8"
Response.ContentType = ContentType

Response.BinaryWrite s.Read
Response.Flush

s.Close
Set s = Nothing
set f=nothing
set fso=nothing
End Function
rs.close
set rs=nothing

%>
...全文
480 16 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
草原可可 2008-01-28
  • 打赏
  • 举报
回复
需要在IIS里配置一下
tvruuiqpl1314520 2008-01-25
  • 打赏
  • 举报
回复
我是通过测试那个下载函数只能下载200M的视频文件,我们的视频文件一般都在700M左右,所以要找能下载大文件的函数
happydayandday 2008-01-24
  • 打赏
  • 举报
回复
顶,关注
star237 2008-01-22
  • 打赏
  • 举报
回复
解决在Windows 2003的 IIS 6.0 中无法上传超过200K的附件以及无法下载超过4M的附件问题

在 IIS 6.0 中,默认设置是特别严格和安全的,最大只能传送 204,800 个字节,这样可以最大限度地减少因以前太宽松的超时和限制而造成的攻击。(在 IIS 6.0 之前的版本中无此限制)

解决办法:
1、先在服务里关闭 iis admin service 服务。
2、找到 windows\system32\inetsrv\ 下的 metabase.xml 文件。
3、用纯文本方式打开,找到 ASPMaxRequestEntityAllowed 把它修改为需要的值(可修改为10M即:10240000),默认为:204800,即:200K。
4、存盘,然后重启 iis admin service 服务。

在 IIS 6.0 中,无法下载超过4M的附件时,可以按以下步骤解决:
1、先在服务里关闭 iis admin service 服务。
2、找到 windows\system32\inetsrv\ 下的 metabase.xml 文件。
3、用纯文本方式打开,找到 AspBufferingLimit 把它修改为需要的值(可修改为2000M即:2048000000)。
4、存盘,然后重启 iis admin service 服务。

其它:默认情况下一般可设置10个网站共用一个程序池,对于大访问量的网站可单独配置程序池,建立新的应用程序池
hspcyeling 2008-01-22
  • 打赏
  • 举报
回复
用迅雷加密法加密,点击自动找迅雷,没有下载不了.
伴老思源 2008-01-22
  • 打赏
  • 举报
回复
-_____________-!

你都限制只能下载200m以内了,

大于200m当然........
tvruuiqpl1314520 2008-01-14
  • 打赏
  • 举报
回复
showbo我用你给的代码试了一下,还是存在问题,我下载970M的文件,只下载下来了23M,下载285M的文件,下载下来只有700K,这个是我用你的代码重新做的,看有什么问题没有

<!--#include file="conn1.asp"-->
<%
dim AsfFile_No,sql,filename
AsfFile_No=request.QueryString("AsfFile_No")

set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from AsfFiles where AsfFile_No='"&AsfFile_No&"'"
rs.open sql,conn,3,3
filename=rs("AsfFile_Name")

Select Case lcase(Right(filename, 4))
Case ".asf"
ContentType = "video/x-ms-asf"
Case ".avi"
ContentType = "video/avi"
Case ".doc"
ContentType = "application/msword"
Case ".xls"
ContentType = "application/vnd.ms-excel"
Case ".gif"
ContentType = "image/gif"
Case ".jpg", "jpeg"
ContentType = "image/jpeg"
Case ".wav"
ContentType = "audio/wav"
Case ".mp3"
ContentType = "audio/mpeg3"
Case ".mpg", "mpeg"
ContentType = "video/mpeg"
Case ".rtf"
ContentType = "application/rtf"
Case ".htm", "html"
ContentType = "text/html"
Case ".txt"
ContentType = "text/plain"
Case Else
ContentType = "application/octet-stream"
End Select
dim ado
dim buffer:buffer=100'缓冲大小
set ado=server.CreateObject("adodb.stream")'stream对象
ado.Mode=3
ado.Type=1
ado.Open
ado.LoadFromFile filename
response.ContentType=ContentType
Response.AddHeader "Content-Disposition", "attachment; filename=filename"
while not ado.EOS
response.BinaryWrite ado.Read(buffer)
response.Flush
wend
ado.Close
set ado=nothing
rs.close
set rs=nothing

%>
  • 打赏
  • 举报
回复
那就奇怪了....
你换种方式,不需要设置这么大的缓存,改为adodb.stream来控制每次下载的块的大小,参考下面的代码

先说明,没测试过

dim ado
dim buffer:buffer=100'缓冲大小
set ado=server.CreateObject("adodb.stream")'stream对象
ado.Mode=3
ado.Type=1
ado.Open
ado.LoadFromFile server.MapPath("menu.xml")
response.ContentType="text/xml"
Response.AddHeader "Content-Disposition", "attachment; filename=menu.xml"
while not ado.EOS
response.BinaryWrite ado.Read(buffer)
response.Flush
wend
ado.Close
set ado=nothing


tvruuiqpl1314520 2008-01-14
  • 打赏
  • 举报
回复
AspBufferingLimit="409600000"
AspMaxRequestEntityAllowed="204800000"
我以设置为这两个值了,但是下载时只能在200M以内
  • 打赏
  • 举报
回复
晕.......................
你都限制只能下载200m以内了,大于200m当然出错了......................
tvruuiqpl1314520 2008-01-14
  • 打赏
  • 举报
回复
我以在IIS下改过下载限制,最多只能下载为200M以内
gingerkang 2008-01-14
  • 打赏
  • 举报
回复
保存批处理运行一下
[code=BatchFile]
echo "配置iis取消上传下载限制"
echo set obj1=GetObject("winmgmts:/root/MicrosoftIISv2") >2003.vbs
echo set obj2=obj1.get("IIsWebServiceSetting='W3SVC'") >>2003.vbs
echo obj2.AspMaxRequestEntityAllowed=52428800 ' 500M upload, u can set to other what you want :) >>2003.vbs
echo obj2.AspBufferingLimit=1073741824 ' 1G set to download, u can set to other what you want :) >>2003.vbs
echo obj2.Put_() >>2003.vbs
cscript 2003.vbs
del 2003.vbs
echo "配置完毕"
[/code]
gingerkang 2008-01-14
  • 打赏
  • 举报
回复
保存批处理运行一下
[code=BatchFile]
echo "配置iis取消上传下载限制"
echo set obj1=GetObject("winmgmts:/root/MicrosoftIISv2") >2003.vbs
echo set obj2=obj1.get("IIsWebServiceSetting='W3SVC'") >>2003.vbs
echo obj2.AspMaxRequestEntityAllowed=52428800 ' 500M upload, u can set to other what you want :) >>2003.vbs
echo obj2.AspBufferingLimit=1073741824 ' 1G set to download, u can set to other what you want :) >>2003.vbs
echo obj2.Put_() >>2003.vbs
cscript 2003.vbs
del 2003.vbs
echo "配置完毕"
[/code]
shanshuiboy 2008-01-14
  • 打赏
  • 举报
回复
帮顶~!~
tvruuiqpl1314520 2008-01-14
  • 打赏
  • 举报
回复
下载视频文件,下载时文件会被系统直接打
<a href="http://192.168.0.121/TechVision Record/TVR_2008-01-14_13-45-02.asf">下载</a>
调用MediaPlayer播放器,如何防止系统直接打开呢?有没有直接调用另存为的命令
  • 打赏
  • 举报
回复
建议楼主还是直接生成连接让用户点击下载得了

刚才我试了下,adodb.stream太占内存了,整个机子都动不了.

<a href="pack.exe">pack(330M)</a>

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧