I am currently validating that I have an image file in Javascript using
file.type.match(/image.*/)
but this is letting through files that are malformed enough not to work in some browsers. For example, a jpg was uploaded that displays fine in Chrome but shows up as malformed in Firefox & Safari (haven't tested IE or Edge yet). I know I can do a more thorough validation in PHP with
exif_imagetype($filepath)
but I wondering if there was a more robust way than match
to do it in Javascript.