0

Is there any way in JavaScript to verify that an uploaded file is in fact an image?

Say I have a .exe file and I change the extension to .png.

Thanks.

iknowmagic
  • 355
  • 1
  • 4
  • 14
  • 1
    You can look for the [magic bytes](https://www.netspi.com/blog/technical/web-application-penetration-testing/magic-bytes-identifying-common-file-formats-at-a-glance/) to identify a file format even when the extension has been changed, but I have no idea how you would implement this in JavaScript. – lejlun Aug 05 '21 at 21:26
  • https://www.npmjs.com/package/file-type – Keith Aug 05 '21 at 21:38
  • Does this answer your question? [How to allow to accept only image files?](https://stackoverflow.com/questions/3828554/how-to-allow-input-type-file-to-accept-only-image-files) – Kosh Aug 05 '21 at 21:54

0 Answers0