Upload this in the project, with a large file upload, to upload the file has more than 100 m, so the study of the domestic use of large files uploaded
Component discovery uses more than two controls Aspnetupload 2.0 and Lion.Web.UpLoadModule, in addition to Shi in its blog
The way the Don says http://blog.joycode.com/saucer/archive/2004/03/16/16225.aspx
The method of two controls is to read data in chunks from the pipe created by IIS for asp.net, using implicit httpworkerrequest and its getpreloadedentitybody and Readentitybody methods. Chris Hynes provides us with a scheme (with HttpModule) that allows you to upload a large file, in real time, to show the upload progress.
Lion.Web.UpLoadModule and Aspnetupload two. NET components are used in this scenario.
When the flyer file, two software methods are the same, inherit HttpModule
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. Cont