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:
- In the MediaWiki installation folder, navigate to the includes directory
- Open the file mime.types in a text editor
- 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/vnd.ms-powerpoint.template.macroEnabled.12 potm application/vnd.openxmlformats-officedocument.presentationml.template potx application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm application/vnd.openxmlformats-officedocument.presentationml.presentation pptx application/vnd.ms-excel.addin.macroEnabled.12 xlam application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb application/vnd.ms-excel.sheet.macroEnabled.12 xlsm application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx application/vnd.ms-excel.template.macroEnabled.12 xltm application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
- Save and close the file.
You should now be able to upload Office documents in the new Open XML File Format.