Asp.net File Upload (exceeding the upload limit of 4 MB) and Multi-File Upload

Source: Internet
Author: User
  1. In the Web. config file, the default upload limit is exceeded by 4 MB, as shown in figure

<Httpruntime
Executiontimeout = "110"
Maxrequestlength = "11000"
Requestlengthdiskthreshold = "80"
Usefullyqualifiedredirecturl = "false"
Minfreethreads = "8"
Minlocalrequestfreethreads = "4"
Apprequestqueuelimit = "5000"
Enablekerneloutputcache = "true"
Enableversionheader = "true"
Requirerootedsaveaspath = "true"
Enable = "true"
Shutdowntimeout = "90"
Delaynotificationtimeout = "5"
Waitchangenotification = "0"
Maxwaitchangenotification = "0"
Enableheaderchecking = "true"
Sendcachecontrolheader = "true"
Apartmentthreading = "false"/>

Set the maxrequestlenth attribute, Which is 11000kb, that is, 11 Mb.


For multi-file uploads, it is also very simple, suchString filepath = "d :\\ lucenedata \\";

Httpfilecollection uploadedfiles = request. files;

For (INT I = 0; I <uploadedfiles. Count; I ++)
{
Httppostedfile userpostedfile = uploadedfiles [I];

Try
{
If (userpostedfile. contentlength> 0)
{
Label1.text + = "<u> file #" + (I + 1) +
"</U> <br> ";
Label1.text + = "file content type:" +
Userpostedfile. contenttype + "<br> ";
Label1.text + = "file size:" +
Userpostedfile. contentlength + "kb <br> ";
Label1.text + = "file name:" +
Userpostedfile. filename + "<br> ";

Userpostedfile. saveas (filepath + "\" +
System. Io. Path. getfilename (userpostedfile. filename ));

Label1.text + = "location where saved:" +
Filepath + "\" +
System. Io. Path. getfilename (userpostedfile. filename) +
"<P> ";
}
}
Catch (exception ex)
{
Label1.text + = "error: <br>" + ex. message;
}
}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.