- .Net Errors (3)
- .Net Question (10)
- 3 – Tier Architecture (2)
- AJAX (2)
- ASP.Net (60)
- ASP.Net – SQL Server (7)
- ASP.Net Controls (16)
- ASP.Net Example (102)
- ASP.Net Objects (4)
- Blog (1)
- Blogger (1)
- C Program (82)
- FileUpload (2)
- JQuery (7)
- PHP (1)
- PROJECT (9)
- SQL (21)
- SQL Function (8)
- SQL-SERVER (24)
- Validation Control (7)
- Web Server (3)
- Windows Application (8)
Check File Size in FileUpload in ASP.Net C#
In previous example we have already learned to use file upload control in ASP.Net.
Here we will learn to check the file size when we upload the file using fileupload control in asp.net.
Now, we tack an example to upload image file, the file must be less than 100kb.
Here, is the layout of fileupload example.
write the below code on button click events to upload file and check size of the image file.
protected void Button1_Click(object sender, EventArgs e)
if (FileUpload1.PostedFile.ContentLength < 102400)
FileUpload1.SaveAs(Server.MapPath(“~/img/”) + FileUpload1.FileName);
Label1.Text = “Image Uploaded Successfully !!”;
Label1.Text = “Image size must be less than 100kb”;
Label1.Text = “Select Image First !!”;
Here is the output of fileupload control exmaple.
Hope this fileupload control example will help you….