Hi,

I tried uploading a .docx file (office word2007) through the standard drupal upload feature, as well as IMCE.
Everytime I then go to download the file through drupal, it seems to have been zipped up, and split into a load of unreadable files.

docx IS allowed in my allowed files list..but makes no difference.

Does anyone know how to cure this problem?

Thanks
Rich

Comments

discorax’s picture

I was having this same problem with Mediawiki Turns out it's a MIME Type issue on the webserver.

I found this blog post from someone that was having that problem on their SBS server. Read about the solution: http://uksbsguy.com/blogs/doverton/archive/2007/03/13/how-to-get-company...

What I had to do was just add in the custom MIME types for the Office 2007 file extensions I wanted to make available for download. Once I put the MIME types on my server everything worked as expected.

Here is the list of all the new Office 2007 MIME types:

'Set the MIME types to be added
' MimeTypesToAddArray = Array(".manifest", "application/manifest", _
' ".xaml", "application/xaml+xml", ".application", "application/x-ms-application", ".deploy", "application/octet-stream", _
' ".xbap", "application/x-ms-xbap")
MimeTypesToAddArray = Array( _
".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" _
)

Hope this helps.

holydrupal’s picture

I added the MIME‌types for the office 2007 in apache>conf>MIMEtype but the files will be download as office 2003 version.
for example if I‌ upload a word document with "docx" format, the file will be converted to doc (the 2003 file system).

I add the below lines in my apache MIME and then restarted:

application/vnd.openxmlformats docx pptx xlsx

any idea?

mrgoz’s picture

In your .htacess you must put this .

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

For more informations read the article:
http://www.webdeveloper.com/forum/showthread.php?t=162526

SteveMM’s picture

Hi -

There is a minor typo in the first "AddType" directive. The line should end with "docm" instead of ".docm" and as a result it appears that Apache ignores everything that follows. Once I made the change, everything worked correctly.

The following article has a few additional mime-type definitions for Office 2007, if you are interested: http://wdg.uncc.edu/Microsoft_Office_2007_MIME_Types_for_Apache_and_IIS.

One final thing - I put the "AddType" directives at the end of my ".htaccess" file. FYI.

Thank you for the information mrgoz - it is appreciated.

Clint Eagar’s picture

I confirm that this solution works for D6.13.

stoob’s picture

As long as you make this change, it works great. Put it in your .htaccess file in the web root

THANKS FOR FIX

malco23’s picture

This fixed a problem I was having with links in Webform that were unable to properly connect to .docx files. THANKS a million

BMDan’s picture

Here's an updated set, borrowed from only official Microsoft sources: http://blogs.msdn.com/b/vsofficedeveloper/archive/2008/05/08/office-2007... and http://technet.microsoft.com/en-us/library/ee309278%28v=office.12%29.aspx. This adds a couple types that the parent post was missing, and also is (hopefully!) typo-free.

AddType application/msword doc
AddType application/msword dot
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
AddType application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
AddType application/vnd.ms-word.document.macroEnabled.12 docm
AddType application/vnd.ms-word.template.macroEnabled.12 dotm
AddType application/vnd.ms-excel xls
AddType application/vnd.ms-excel xlt
AddType application/vnd.ms-excel xla
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
AddType application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
AddType application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
AddType application/vnd.ms-excel.template.macroEnabled.12 xltm
AddType application/vnd.ms-excel.addin.macroEnabled.12 xlam
AddType application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
AddType application/vnd.ms-powerpoint ppt
AddType application/vnd.ms-powerpoint pot
AddType application/vnd.ms-powerpoint pps
AddType application/vnd.ms-powerpoint ppa
AddType application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
AddType application/vnd.openxmlformats-officedocument.presentationml.template potx
AddType application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
AddType application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam
AddType application/vnd.ms-powerpoint.presentation.macroEnabled.12 pptm
AddType application/vnd.ms-powerpoint.template.macroEnabled.12 potm
AddType application/vnd.ms-powerpoint.slideshow.macroEnabled.12 ppsm
drupalmind’s picture

i am having problem docx file is opening into the explorer with bad characters instead of download.
using filefield module.

ishiomin’s picture

I had the same problem but only with IE7 and not with firefox 3 or google chrome.
Thank you mrgoz : I installed the AddType directives in httpd.conf

lelizondo’s picture

I had to configure apache to not do this for every site I add

For apache2 I edited /etc/mime.types

application/vnd.ms-word.document.macroEnabled.12 docm
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 

Info extracted from http://www.webdeveloper.com/forum/showpost.php?p=1005540&postcount=11

Works with Ubuntu and Apache 2

Luis

tovstiadi’s picture

... you can add MIME types to Apache via the Server Admin application:

Web > Settings > MIME types

Drupal Centric’s picture

I added those lines of code to my htaccess file and it worked for some docx files but not all, any ideas? I'm using Views to display a link to download the file.