Wednesday, February 24, 2010

Adding mime types for Microsoft Office 2007 file types in Apache

When opening uploaded documents from Microsoft Office 2007 applications in MediaWiki (and some other web applications as well) they might turn up as zip-files or doesn't start the appropriate office application. This is due to the fact that Office Open XML (OOXML) is a zip based file format and Apache 1 and 2 doesn't yet come with updated mime type definitions (or IANA haven't registered them).

You can add these missing definitions yourself without much trouble. First locate the Apache mime types table (mime.types) and then just add the following and restart your apache server.

application/ docm
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
application/ potm
application/vnd.openxmlformats-officedocument.presentationml.template potx
application/ ppam
application/ ppsm
application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
application/ pptm
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
application/ xlam
application/ xlsb
application/ xlsm
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/ xltm
application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx

For MediaWiki to identify the correct mime type (during upload) you can also add the above unmodified to includes/mime.types.

The MediaWiki file includes/ has no practical use currently but you could add the following to it for completeness:

application/ [OFFICE]
application/vnd.openxmlformats-officedocument.wordprocessingml.document [OFFICE]
application/vnd.openxmlformats-officedocument.wordprocessingml.template [OFFICE]
application/ [OFFICE]
application/vnd.openxmlformats-officedocument.presentationml.template [OFFICE]
application/ [OFFICE]
application/ [OFFICE]
application/vnd.openxmlformats-officedocument.presentationml.slideshow [OFFICE]
application/ [OFFICE]
application/vnd.openxmlformats-officedocument.presentationml.presentation [OFFICE]
application/ [OFFICE]
application/ [OFFICE]
application/ [OFFICE]
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet [OFFICE]
application/ [OFFICE]
application/vnd.openxmlformats-officedocument.spreadsheetml.template [OFFICE]

Finally remember to add the file types to the variable $wgFileExtensions in LocalSettings.php.

1 comment:

  1. Personally it seems to me that this version of the software is too outdated and better updated to a more recent version of this program, I personally have already done it and the only thing I do not like is the amount of standard templates. Personally, I download them here I recommend to everyone.