In an attempt to save someone some heartache, I'm going to write up about a problem that I've seen, but hasn't been well documented. The new Office 2007 file extensions (docx,potx,xlsx,etc) turning into ZIP files when they are uploaded to a web server and then downloaded.

The new Office 2007 file formats are now using an Open XML file format system so they are more compatible with other office programs from Google, Open Office...etc. Essentially they are ZIP files that are full of XML files that when opened with the a proper application turn into a friendly word document. While that's pretty nice of Microsoft, they haven't been to good about release MIME type information for these file formats which can cause some interesting issues when trying to upload and download them to a webserver.

I stumbled onto this problem while I was working with MediaWiki. I was uploading Office 2007 files (docx to be precise) and when my co-workers went to download them on Vista, they would save as .zip files. When they tried to open them up they were just a bunch of XML files which to the untrained eye would be a bunch of gobbledygook.

I was tasked with solving this problem. After searching the internet for a good 2 hours I stumbled onto a post on a DRUPAL blog. Someone was asking about this problem using Drupal. So I thought, what do Drupal and MediaWiki have in common...php/mysql backend was what I came up with.

So after doing some more research I found a blog post written by Dave Overton. He was trying to solve that same problem for a local SBS server. He found a solution that involved the MIME Types on the server. The lightbulb went off.

Since Office 2007 is new and Vista is new a web server isn't going to know what application runs what file extension. At some point Microsoft will release an update (I hope) but until them we can just add in the appropriate MIME Types to our web servers and that should give us the results we want.

I put up the list of office 2007 file extensions and their MIME Types on to the server hosting my MediaWiki and just like that everything worked. Here is the list of Office 2007 MIME type associations you can add if you run into this same problem.

Code:
".manifest", "application/manifest"
".xaml", "application/xaml+xml", 
".application",  "application/x-ms-application", 
".deploy", "application/octet-stream"
".xbap", "application/x-ms-xbap"

".docm","application/vnd.ms-word.document.macroEnabled.12" 
".docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document" 
".dotm","application/vnd.ms-word.template.macroEnabled.12" 
".dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template" 
".potm","application/vnd.ms-powerpoint.template.macroEnabled.12" 
".potx","application/vnd.openxmlformats-officedocument.presentationml.template" 
".ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12" 
".ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12" 
".ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow" 
".pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12" 
".pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation" 
".xlam","application/vnd.ms-excel.addin.macroEnabled.12" 
".xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12" 
".xlsm","application/vnd.ms-excel.sheet.macroEnabled.12" 
".xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" 
".xltm","application/vnd.ms-excel.template.macroEnabled.12" 
".xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"