is there an easy way to get the content type of a file?

I am working on a file sharing script and i need to get the file content type for download.

the only way i can think of is like having a database with all the different content types and getting it by the file extension...