How can I find out what file extension a specified file is?

I need to have my script check to see if the file a user selects is certain file type. If the file they select is not a file type my script supports, the script returns an error.