Below is the code for "Upload" button when uploading any file:
if (contenttype != String.Empty)
{
if (File.Exists(Server.MapPath("~/Folder/'" + Txt.Text + "'/") + filename))
{
LMsg.Visible = true;
LMsg.ForeColor = Color.Red;
LMsg.Text = "File name '" + filename + "' already exist. Please change the File name to save this file";
}
else
{
//saving multiple file OR 1 file in newly created folder
if (FileUpload.HasFile)
{
for (int i = 0; i < Request.Files.Count; i++)
{
HttpPostedFile file = Request.Files[i];
if (file.ContentLength > 0)
{
string fileName = Path.GetFileName(file.FileName);
file.SaveAs(Server.MapPath("~/Folder/'" + Txt.Text + "'/") + fileName);
}
}
Response.Redirect(Request.Url.AbsoluteUri);
}
}
}
else
{
LMsg.Visible = true;
LMsg.ForeColor = System.Drawing.Color.Red;
LMsg.Text = "File format not recognised." + " Upload Image/Word/PDF/Excel formats";
}
file upload control allows maximum file size is 4MB. If file size increase to 4MB it shows error page like "the page can not displayed".
I want to increase the size of uploaded files to max 10 MB not more than that. If file size increase to 10MB, it should show message.
Please reply.