I would like to detect the MIME type of a file on the client side of my application using jQuery or JavaScript. Is there a way to do this? Thanks.
You could use AJAX, make a HEAD request, and inspect the response headers for the Content-type header. But that only works if you're getting a file from a HTTP server.
To get the MIME type of a file chosen with an HTML file chooser, without submitting anything, try:
document.getElementById('fileChooserID').files[0].type // e.g. image/png
Example
http://jsbin.com/akati3/2
Try choosing an image, check the MIME type, and try to submit it. Then try something else that's not an image.