Check Valid Imag File

Lakhangarg
Posted by Lakhangarg under ASP.NET category on | Views : 2575
Hi Check file type and return true if its of gif, jpeg, pjpeg, png, jpg, bmp etc if it is of any other type then return false.
public static bool CheckValidJPGGIF(ref FileUpload file)
{
if (file.PostedFile.ContentType.ToLower() == "image/gif" || file.PostedFile.ContentType.ToLower() == "image/jpeg" || file.PostedFile.ContentType.ToLower() == "image/pjpeg" || file.PostedFile.ContentType.ToLower() == "image/x-png" || file.PostedFile.ContentType.ToLower() == "image/jpg" || file.PostedFile.ContentType.ToLower() == "image/bmp")
{
return true;
}
else
{
return false;
}
}

Comments or Responses

Login to post response