I have a scenario wherein user is trying to view an invalid image file (for example an .dll file renamed to JPG extenstion). How do I alert the user using JavaScript that this is an invalid file?
3 Answers
There is a way of doing it with javascript.
If the browser supports window.FileReader and window.Blob, which most do, then yes, you can.
if ( window.FileReader && window.Blob ) { // get your file from wherever... // tacky check jpg in the mime type if ( yourFile.type.indexOf("jpeg") ) { .... } }