Answer the question
In order to leave comments, you need to log in
How to accurately determine the type of the selected file on the disk?
The user will select a "new avatar" via the OpenDialog which will return the path to the file.
I'm loading a file from disk and sending it to a Node.js server.
On the server, I need to accurately determine that the resulting file is a picture and not something else.
I read an article on Habré: https://habrahabr.ru/post/44610/
It became scary.
Answer the question
In order to leave comments, you need to log in
https://www.npmjs.com/package/mime
Also, don't forget about the accept attribute:
https://developer.mozilla.org/en-US/docs/Web/HTML/...
stackoverflow.com/questions /181214/file-input-acce...
// EDIT
https://www.npmjs.com/package/file-type
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question