Let\'s say you want to save a bunch of files somewhere, for instance in BLOBs. Let\'s say you want to dish these files out via a web page and have the client automatically o
You didn't state what web server you were using, but Apache has a nice little module called Mime Magic which it uses to determine the type of a file when told to do so. It reads some of the file's content and tries to figure out what type it is based on the characters found. And as Dave Webb Mentioned the MimeTypes Module under python will work, provided an extension is handy.
Alternatively, if you are sitting on a UNIX box you can use sys.popen('file -i ' + fileName, mode='r')
to grab the MIME type. Windows should have an equivalent command, but I'm unsure as to what it is.