ASP.NET上传大文件
文件一般在300M~600M(电影),网上也搜了一下,至今没找到好的方法.
至于用.Net中的FileUpload控件,修改Web.config这个方法不是很好,全部读入到内存简直就是死机了,
大部分网页都提到思归的那篇文章
http://blog.joycode.com/saucer/archive/2004/03/16/16225.aspx
看了之后,如果用SlickUpload的话,还收费,99美圆,感觉很贵(如果谁买过可以免费给我还行,破截的在参考范围之类)
还有就是这断代码,最关键用 ".... "替代了,汗~
IServiceProvider provider = (IServiceProvider) HttpContext.Current;
HttpWorkerRequest wr = (HttpWorkerRequest) provider.GetService(typeof(HttpWorkerRequest));
byte[] bs = wr.GetPreloadedEntityBody();
....
if (!wr.IsEntireEntityBodyIsPreloaded())
{
int n = 1024;
byte[] bs2 = new byte[n];
while (wr.ReadEntityBody(bs2,n) > 0)
{
.....
}
}
谁能提供一个NB的解决方法,最好以前解决过类似问题.
还有就是到处是这个代码
HttpApplication application1 = sender as HttpApplication;
HttpWorkerRequest request1 = (HttpWorkerRequest) ((IServiceProvider) HttpContext.Current).GetService(typeof(HttpWorkerRequest));
try
{
if (application1.Context.Request.ContentType.IndexOf( "multipart/form-data ") <= -1)
{
return;
}
//Check The HasEntityBody
if (!request1.HasEntityBody())
{
return;
}
int num1 = 0;
TimeSpan span1 = DateTime.Now.Subtract(this.beginTime);
string text1 = application1.Context.Request.ContentType.ToLower();
byte[] buffer1 = Encoding.ASCII.GetBytes(( "\r\n-- " + text1.Substring(text1.IndexOf( "boundary= ") + 9)).ToCharArray());
int num2 = Convert.ToInt32(request1.GetKnownRequestHeader(11));
Progress progress1 = new Progress();
application1.Context.Items.Add( "FileList ", new Hashtable());
byte[] buffer2 = request1.GetPreloadedEntityBody();
num1 += buffer2.Length;
string text2 = this.AnalysePreloadedEntityBody(buffer2, "UploadGUID ");
if (text2 != string.Empty)
{
application1.Context.Items.Add( "LionSky_UpLoadModule_UploadGUID ", text2);
}
bool flag1 = true;
if ((num2 > this.UpLoadFileLength()) && ((0 > span1.TotalHours) || (span1.TotalHours > 3)))
{
flag1 = false;
}
if ((0 > span1.TotalHours) || (span1.TotalHours > 3))
{
flag1 = false;
}
string text3 = this.AnalysePreloadedEntityBody(buffer2, "UploadFolder ");
ArrayList list1 = new ArrayList();
RequestStream stream1 = new RequestStream(buffer2, buffer1, null, RequestStream.FileStatus.Close, RequestStream.ReadStatus.NoRead, text3, flag1, application1.Context, string.Empty);
list1.AddRange(stream1.ReadBody);
if (text2 != string.Empty)
{
progress1.FileLength = num2;
progress1.ReceivedLength = num1;
progress1.FileName = stream1.OriginalFileName;
progress1.FileCount = ((Hashtable) application1.Context.Items[ "FileList "]).Count;
application1.Application[ "_UploadGUID_ " + text2] = progress1;
}
if (!request1.IsEntireEntityBodyIsPreloaded())
{
byte[] buffer4;
ArrayList list2;
int num3 = 204800;
byte[] buffer3 = new byte[num3];
while ((num2 - num1) > = num3)
{
if (!application1.Context.Response.IsClientConnected)
{
this.ClearApplication(application1);
}
num3 = request1.ReadEntityBody(buffer3, buffer3.Length);
num1 += num3;
list2 = stream1.ContentBody;
if (list2.Count > 0)
{
buffer4 = new byte[list2.Count + buffer3.Length];
list2.CopyTo(buffer4, 0);
buffer3.CopyTo(buffer4, list2.Count);
stream1 = new RequestStream(buffer4, buffer1, stream1.FileStream, stream1.FStatus, stream1.RStatus, text3, flag1, application1.Context, stream1.OriginalFileName);
}
else
{
stream1 = new RequestStream(buffer3, buffer1, stream1.FileStream, stream1.FStatus, stream1.RStatus, text3, flag1, application1.Context, stream1.OriginalFileName);
}
list1.AddRange(stream1.ReadBody);
if (text2 != string.Empty)
{
progress1.ReceivedLength = num1;
progress1.FileName = stream1.OriginalFileName;
progress1.FileCount = ((Hashtable) application1.Context.Items[ "FileList "]).Count;
application1.Application[ "_UploadGUID_ " + text2] = progress1;
}
}
buffer3 = new byte[num2 - num1];
if (!application1.Context.Response.IsClientConnected && (stream1.FStatus == RequestStream.FileStatus.Open))
{
this.ClearApplication(application1);
}
num3 = request1.ReadEntityBody(buffer3, buffer3.Length);
list2 = stream1.ContentBody;
if (list2.Count > 0)
{
buffer4 = new byte[list2.Count + buffer3.Length];
list2.CopyTo(buffer4, 0);
buffer3.CopyTo(buffer4, list2.Count);
stream1 = new RequestStream(buffer4, buffer1, stream1.FileStream, stream1.FStatus, stream1.RStatus, text3, flag1, application1.Context, stream1.OriginalFileName);
}
else
{
stream1 = new RequestStream(buffer3, buffer1, stream1.FileStream, stream1.FStatus, stream1.RStatus, text3, flag1, application1.Context, stream1.OriginalFileName);
}
list1.AddRange(stream1.ReadBody);
if (text2 != string.Empty)
{
progress1.ReceivedLength = num1 + buffer3.Length;
progress1.FileName = stream1.OriginalFileName;
progress1.FileCount = ((Hashtable) application1.Context.Items[ "FileList "]).Count;
if (flag1)
{
progress1.UploadStatus = Progress.UploadStatusEnum.Uploaded;
}
else
{
application1.Application.Remove( "_UploadGUID_ " + text2);
}
}
}
byte[] buffer5 = new byte[list1.Count];
list1.CopyTo(buffer5);
this.PopulateRequestData(request1, buffer5);
}
catch (Exception exception1)
{
this.ClearApplication(application1);
throw exception1;
}
能运行?
[解决办法]
帮忙UP,学习下,以前都是webconfig,有弊端没错。
[解决办法]
UP起来,高手们睁开眼看看吧!我也正遇到这问题!
[解决办法]
大文件上传和下载都是问题
[解决办法]
介绍你一个好的控件,好象叫什么r.a.d control,去网上搜一下,那个上传大文件,速度快的很那
[解决办法]
我找了好多天,终于到网上找到了个开源的!
带进度条,很好用!那个要的跟我发EMAIL:sunxw18@163.com
呵呵
[解决办法]
你提供个邮箱 我发你一份吧
SlickUpload那个项目是我反编译人家的,去除了Evaluation版信息,不好放在这供大家下载
[解决办法]
MARK
[解决办法]
up
[解决办法]
最好还是想办法搞成FTP的好。HTTP协议决定了上传大文件总不是好的解决方案
[解决办法]
顶一下,好象沉了
[解决办法]
用FTP控件吧,百度上搜索一下,功能都很强大的。
[解决办法]
对sunxw18()这种人
我表示鄙视
有了就把网址共享乐吧
还搞什么邮箱,是不是故意收集我们的邮箱啊
一点没有开源的想法
[解决办法]
LZ 给你发私信了, 帮你顶呵呵
[解决办法]
用FTP
[解决办法]
300,400M....还是用个FTP吧。。。BS这个。怕是不好实现的说。。。我以前也试过。。没有成功。。
[解决办法]
sunxw18() :
也麻烦给我发一份吧,谢谢。
+++++++++++++++++++++++++++++++
我的邮箱: 31350709@qq.com
[解决办法]
http://community.csdn.net/Expert/topic/5118/5118124.xml?temp=.2376978
[解决办法]
有好东西共享一下吧
fyaoyao31@163.com
------解决方案--------------------
http://www.cnblogs.com/Files/WuCountry/WebbUploadSample.rar
WebbUpload上传组件
[解决办法]
记号`
[解决办法]
也麻烦给我发一份吧,谢谢。
我的邮箱: micrhua@gmail.com
[解决办法]
麻烦给我发一份,谢谢。yj0867_cn@sina.com
[解决办法]
Thomas.net@163.com
谁给我发一份啊
另外邀请人加入 asp.net 开源软件交流群
28841212
[解决办法]
我也要,麻烦你帮我传一个,谢谢
fire_dreamland@sina.com
[解决办法]
mark
[解决办法]
楼主其实已经有核心代码了,再改改就出来了!