Files Types for Uploading Office Documents

I wanted to have an “allowed” list of file types for uploading, but upon looking at just a few different files on my own computer I see each one is completely different.

  1. vnd.openxmlformats-officedocument.wordprocessingml.document
  2. application/vnd.ms-excel
  3. vnd.openxmlformats-officedocument.spreadsheetml.sheet
  4. application/octet-stream
  5. application/msword

The first four are excel documents, and I only tried four excel documents so I’m worried there may be a bunch of others. If I knew “vnd.openexcelformats”, “vnd.ms-excel” and “octet-stream” were the only formats then it wouldn’t be a problem. I doubt it though. Any ideas what all the possible types are for all office documents? Word, Access, etc.

Here is a list of the newer microsoft office mime types: http://filext.com/faq/office_mime_types.php

You could also just check against file extension.

Always be careful with that, as it’s a pretty easy attack vector. MIME sniffing also isn’t problem free, but better than extension checking IMHO.