A few days ago, I downloaded a large file upload example on 51aspx .. I tried it .. it takes only 50 seconds for a 119 M object. I was still thinking about it. study hard. then write a normal upload example and compare it. just modified the configuration file. I tested 119 M and it was also 50 seconds .. only then can we find that this example is truly confusing...CodeTens of thousands of lines are written. How to set all. the upload status does not improve the upload efficiency...
Multi-File Upload
First, add the HTML component for file upload to the HTML source file.
<Script language = "JavaScript" type = "text/JavaScript">
Function AddFile ()
{
// Add an HTML component for File Upload
VaR STR = '<input type = "file" name = "file"/> </BR>'
Document. getelementbyid ('myfile'). insertadjacenthtml ("beforeend", STR)
}
</SCRIPT>
Background:
Httpfilecollection files = httpcontext. Current. Request. files;
For (INT ifile = 0; ifile <files. Count; ifile ++)
{
Httppostedfile postedfile = files [ifile];
String filename, fileextension;
Filename = system. Io. Path. getfilename (postedfile. filename );
If (filename! = "")
{
Fileextension = system. Io. Path. getextension (filename );
Postedfile. saveas (system. Web. httpcontext. Current. Request. mappath ("FLL/") + filename );
}
}
Response. Write ("the file is uploaded successfully! ");
When uploading large files, you need to modify the configuration file:
<Httpruntime usefullyqualifiedredirecturl = "true" maxrequestlength = "1024000" executiontimeout = "900"/>