Determine if the file is really an image in express / node.js

How to check if a file uploaded on my server really is an image? Not only a file with the extension (jpg, png, gif) to make it an "image file". I created an image compression service using imagemin, but I'm afraid that the downloaded file is really an image.

+7
express
source share
2 answers

I used the mmmagic module for this, it detects mime types: mmmagic in Github

+4
source share

Mig types are not useful. Try magic numbers or try opening a file. Read the link for more details. fooobar.com/questions/400389 / ...

http://www.astro.keele.ac.uk/oldusers/rno/Computing/File_magic.html#Image

+1
source share

All Articles