Office 2007 and Zip files

by Adrian Palmer on October 23rd, 2009 | Posted in Revium Sandbox | Comment on this entry

Recently one of our clients reported that some visitors were having problems downloading Office 2007 (Word, Excel and Powerpoint) files that they had uploaded via their Wordpress CMS, that we had implemented for them. The problems they reported were that some visitors, who were using Internet Explorer were downloading docx, xlsx and pptx files and their computers were opening them as though they were zip files.

My first thoughts upon hearing this problem is that there was some kind of Wordpress issue and how it handled file uploads. Wordpress is blogging platform and a content management system and might not have been equipped to deal with these kinds of document types correctly yet. Well, at least not on Internet Explorer. A few searches around the web and more specifically the wordpress support forums really did not throw much light on the situation, which lead me to believe the problem lay elsewhere.

Knowing that the problem only affected Internet Explorer, I assumed that the problem could not be related to anything other than this browser as no others were affected. However, a lot of frantic googling later, I discovered that what was happening was basically as follows:

  1. The web server (in this case, Apache) serves the file without the correct Mimetype
  2. The browser downloads the file and then different browsers handle the files in different ways.

In the case of browsers such Firefox, Safari and Chrome, the file is handed off to the correct application dictated by the file extension, so in this case the files are opened correctly with Office 2007 (presuming the computer has been setup with the correct filetype associations). I am not sure of the security implications of opening something by relying on just the file extension to dictate the type of file it is, I will leave that matter for someone more intelligent and informed than myself to debate.

However, in the case of Internet Explorer, due to the absence of a mimetype supplied by the server, it appears to look at the file contents for the type of file it is. So why is it opening it as a zip file in that case? Well, from what I can gather the new file formats introduced with Office 2007 are based on zip files that contain all the necessary resources for that document, so Internet Explorer is seeing it as a zip file and sending it to whichever program you have installed that is associated with Zip files.

So how do we fix this issue and make Internet Explorer handle the files correctly? We need to explicitly tell the server to serve the files with the correct mimetype, in the case of Apache, we can do this by adding certain rules to the .htaccess file at the root of your server.

The following rules should be added near the beginning of your file and they tell the server what mimetypes to associate with each file extension. Once you have added these and uploaded the file, Internet Explorer should download the files correctly.

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

Related posts:

  1. Wordpress Custom Fields and Default Values
  2. Why does Revium use Wordpress?
  3. Sorting out SVN checkin/checkout issues
  4. Revium’s Part in ANZ Rebranding
  5. 5 things I learnt this week

« Limiting LINQ String Field Lengths

Degrading Script Tags »

Leave a Reply

Click here to cancel reply.

Recent Articles

  • Return of the daily sites
  • Collaborating with Government
  • Ya-bing-ooo!! Yahoo search is dead long live the Bing.
  • Social Media – Good For Some
  • 10 Tips for user acceptance testing of web applications
  • Popular Content Management Systems
  • ASP.NET MVC [HandleError] and logging
  • VMWare hard lessons

Twitter

  • Collaborating with Government: Revium is actively involved in the Federal Government’s R&D program for tax concess... http://bit.ly/9D7Vc6 1 week ago
  • 45 Free Applications For Web Designers & Developers http://www.noupe.com/tools/45-free-applications-for-designers-and-developers.html 1 week ago
  • In most watch advertisements the time displayed on the timepiece is 10:10 because then the arms frame the brand of the watch. 1 week ago
  • More updates...

Revium Logo

  • Home
  • About
  • Expertise
  • Showcase
  • Contact

  • news
  • blog
  • sandbox
  • twitter
  • facebook
  • rss
Bookmark and Share

We are Revium, hear us roar!

The news.

31 Aug

Collaborating with Government

Revium is actively involved in the Federal Government’s R&D program for tax concessions to develop our in-house products that we are looking to take…

Continue reading
View archive

The blog.

01 Sep

Return of the daily sites

Years ago I used to have a morning routine of checking a select few websites I came across. For one reason or another I…

Continue reading
View archive

The sandbox.

20 Aug

Ya-bing-ooo!! Yahoo search is dead long live the Bing.

Ya-bing-oo!! Yahoo search is dead long live the Bing In July 2010 Yahoo had started testing Bing powered search they routed 25% of their search…

Continue reading
View archive

eNewsletter.

 

© Copyright 2010. All Rights Reserved.

Revium Pty Ltd

e / info@revium.com.au t / Work +61 3 9429 2000

Find us: web development, seo

Disclaimer and privacy Revium Pty Ltd

10 Harvey Street
Richmond, Victoria, 3121 Australia
View map

Logo Partner MicrosoftLogo Partner KenticoLogo Partner IiaLogo Partner Iia RibLogo Partner Acs