In my webapp I am allowing users to Upload Videos and Pictures. I was running into Maximum Size Exceeded error and found the fix using this Maximum Request Length Exceeded
But my question is for my Images controller I want to keep a 4mb limit as default. I only want to apply the solution in the link to Video controller. Is this possible? Also is there a way to add a ModelState error to check the file size before uploading? My controller action looks like
if (m.File == null)
{
ModelState.AddModelError("File", "You did not slect any file");
return View();
}
if (m.File.ContentLength > 0)
{
var fileName = System.IO.Path.GetFileName(m.File.FileName);
byte[] uploadedFile = new byte[m.File.InputStream.Length];
m.File.InputStream.Read(uploadedFile, 0, uploadedFile.Length);
// ..... Savefile and return
}
However in this action I've tried if (m.File.ContentLength > 4194304)
and it returns false until the complete file is uploaded on server. So my second question is how to check the file size on server without uploading?