Not exactly an answer to your question, but rather an aside:
Checking the type
value does not tell you anything at all. This value is produced by the browser and is not checked by PHP on the server side (many similar questions here on SO have answers pointing this out -- check the "related" sidebar on the right). Browsers can be configured to send anything at all for any specified file extension, so if you use this value you are in effect blindly trusting user input (bad).
It's better to just extract the extension from the filename and do what you will with that.
Update: I didn't expect to be upvoted too much, but as things stand I feel I should provide some more information.
If you aren't OK with working with just the file extension, you can get the MIME type of a file by using the fileinfo
functions as usoban says. Unfortunately, that's only available on PHP 5.3 and up.
A more compatible option is presented as the answer to
How to get the content-type of a file in PHP? here on SO (although I find the answer as presented to be a bit of overkill, it's good by any standard).