Restricting user to upload a file of specific size

Sandhyab
Posted by Sandhyab under ASP.NET category on | Points: 40 | Views : 863
  public int maxSize { get; set; }

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
maxSize = 1048576;
}

}

protected void lnkAttach_Click(object sender, EventArgs e)
{
if (FileUpload1.PostedFile.ContentLength < maxSize)
{
//Implementation
}

else
{
lblrMessage.Text = "File Size ShouldNot Exceed More than 1 MB";
}
}

Comments or Responses

Login to post response