Monday, March 8, 2010

File Upload. Verifying file type

string fname = FileUpload1.FileName;

string fileext = fname.Substring(fname.LastIndexOf(".")+1).ToLower();

if (fileext != "jpg" && fileext != "gif" && fileext != "png" && fileext != "jpeg")
 {

 lblError.Text="Logo should be of type jpg,jpeg,gif,png...";
  return;

  }
else
{
fileUpload1.Postedfile.SaveAs("");

}

No comments:

Post a Comment