I’m developing some website with ASP.Net for uploading and processing some MS word docs. and I get connection was interrupted in Chrome or connection was reset in firefox for uploading docs bigger than 4 MB. I get this error as soon as I push the button and it almost upload nothing.
it’s the part of the code I think causes the error (I use the common input type=file for upload slot)
if (filMyFile.PostedFile != null)
{
// Get a reference to PostedFile object
HttpPostedFile myFile = filMyFile.PostedFile;
// Get size of uploaded file
int nFileLen = myFile.ContentLength;
// make sure the size of the file is > 0
if (nFileLen > 0)
{
// Allocate a buffer for reading of the file
byte[] myData = new byte[nFileLen];
// Read uploaded file from the Stream
myFile.InputStream.Read(myData, 0, nFileLen);
// Create a name for the file to store
string strFilename = Path.GetFileName(myFile.FileName);
// Write data into a file
WriteToFile(Server.MapPath(strFilename), ref myData);
where do you think the problem is? thanks
The 4MB is default limit set in machine.config. You can extend upload file limit by adding
<httpRuntime/>element in web.config file. For more detail read this post.