Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Check if uploaded IFormFile is a valid image

$
0
0

Hi,

I'm trying my best to find a solution to this:

I need the controller to check if the uploaded file is a valid image (not just extention or contenttype) I need it to validate that it is an image.

The problem that solutions that I found such as this:

try
{
    using (var bitmap = new System.Drawing.Bitmap(myFile.InputStream))
    {
    }
}
catch (Exception)
{
    return false;
}

are not applicable in Core as Drawing class is not available. 

Thanks a lot


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>