Tuesday, 16 October 2012


Checking Extension While Uploading



if (FileUpload1.FileName != "")
        {
            string ext = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower();
            if (!(ext == ".jpg" || ext == ".png" || ext == ".gif"))
            {
                lblMessage.Text = "Sorry! Image can be JPG,PNG,GIF only";
                return;
            }

            if (FileUpload1.FileBytes.Length > 150000)
            {
                lblMessage.Text = "Sorry! Image can be upto 150KB only";
                return;
            }
        }

No comments:

Post a Comment