While user uploading a file, is it possible to know if the uploaded file is an image or not,
I am open for any solution, Client Side, Server Side or both and we choose based on the case.
While user uploading a file, is it possible to know if the uploaded file is an image or not,
I am open for any solution, Client Side, Server Side or both and we choose based on the case.
May be you can use following code to check if the file is an image.
public bool IsFileAnImage(string filePath)
{
try
{
Image image = Image.FromFile(filePath))
}
catch
{
return false;
}
finally
{
image.Dispose();
}
return true;
}