That's why don't depend on allowed contentType approach, otherwise you will face cross browser compatibility issues. Do it manually yourself using this class http://download.oracle.com/javase/6/docs/api/javax/activation/MimetypesFileTypeMap.html. The weird problem i faced mentioned allowed types image/jpeg and i'm uploading a jpeg file but the browser is identifying that file as application/oct-stream and not allowing to upload. Never give a chance to decide your file content type and different browsers will identify the file content type differently sometimes.
ocjp 6 — Feeding a person with food is a great thing in this world. Feeding the same person by transferring the knowledge is far more better thing. The reason is the amount of satisfaction which we get through food is of only one minute or two. But the satisfaction which we can get through the knowledge is of life long.
Here, identifying the file contentType by using file extension, Let us assume a smart user modified the file extension. Obviously it will give wrong mime type. What we can do more make it more accurate?
Source code from MimeTypesFileTypeMap.java
subject: file upload problem using internet explorer 8