.docx files and functions.php
-
Hi. We were having problems with our WordPress install and .docx files. We’d successfully added the ability to upload these to posts, and everything was working fine until the links were clicked.
If we chose to open the file directly in Word, we found the .doc suffix was being added to the file, despite .docx already being there – so test.docx would become test.docx.doc.
This was a cross-browser, cross-machine issue for us. Saving files to disk and then opening them worked fine and .docx files on the server outside of WordPress worked fine.
We were able to fix this by editing wp-includes/functions.php, which has two entries for .docx files in its MIME types array.
On line 2489: ‘doc|docx’ => ‘application/msword’,
On line 2498: ‘docx|dotx’ => ‘application/vnd.openxmlformats-officedocument.wordprocessingml’,
I figured the script was hitting the first match and sending a MIME type that suggested the file was Word 97-2003 (the .docx files were being identified as this prior to opening on my PC), and I knew Apache – which was working – was sending the second type, which the script would presumably never get to.
We changed line 2489 to ‘doc’ => ‘application/msword’, so .docx files only matched the second line, and the links started working.
I don’t know if this warrants a bug report, so I thought I’d bring it up here first to see what people think.
- The topic ‘.docx files and functions.php’ is closed to new replies.