Uploading docx, pptx, xlsx and other Office formats to MediaWiki

Enable the upload of Microsoft Office document files to MediaWiki without modifying any source code.

Tags: mediawiki office


When attempting to upload Office 2007 or Office 2010 documents (.docx, .pptx, .xlsx etc.) to MediaWiki, you will see the following error message:

Cannot upload this file because Internet Explorer would detect it as "application/zip", which is a disallowed and potentially dangerous file type

The newer Microsoft Office file formats use the Open XML File Format introduced with Office 2007. These files are actually ZIP containers that contain multiple XML files describing the properties and data of an Office document. MediaWiki uses the MimeMagic module to detect the format of uploaded files.

Because the file extensions for the new Office formats are currently not in MediaWiki‘s list of known MIME types, MimeMagic attempts to guess the file format based on the file data and correctly identifies these as ZIP files, which are subsequently blocked from uploading due to security concerns.


Various articles on the internet – including the official bug fix – suggest to hack the MIME type checking code in MediaWiki or to disable the checking feature altogether. The better solution is to add the missing file extensions to MimeMagic‘s list of known MIME types.

To add the new MIME types, perform the following steps:

  1. In the MediaWiki installation folder, navigate to the includes directory
  2. Open the file mime.types in a text editor
  3. Append the following lines to the end of the file:
    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
  4. Save and close the file.

You should now be able to upload Office documents in the new Open XML File Format.

Related Resources