In an attempt to save someone some heartache, I'm going to write up about a problem that I've seen, but hasn't been well documented. The new Office 2007 file extensions (docx,potx,xlsx,etc) turning into ZIP files when they are uploaded to a web server and then downloaded.
The new Office 2007 file formats are now using an Open XML file format system so they are more compatible with other office programs from Google, Open Office...etc. Essentially they are ZIP files that are full of XML files that when opened with the a proper application turn into a friendly word document. While that's pretty nice of Microsoft, they haven't been to good about release MIME type information for these file formats which can cause some interesting issues when trying to upload and download them to a webserver.
I stumbled onto this problem while I was working with MediaWiki. I was uploading Office 2007 files (docx to be precise) and when my co-workers went to download them on Vista, they would save as .zip files. When they tried to open them up they were just a bunch of XML files which to the untrained eye would be a bunch of gobbledygook.
I was tasked with solving this problem. After searching the internet for a good 2 hours I stumbled onto a post on a DRUPAL blog. Someone was asking about this problem using Drupal. So I thought, what do Drupal and MediaWiki have in common...php/mysql backend was what I came up with.
So after doing some more research I found a blog post written by Dave Overton. He was trying to solve that same problem for a local SBS server. He found a solution that involved the MIME Types on the server. The lightbulb went off.
Since Office 2007 is new and Vista is new a web server isn't going to know what application runs what file extension. At some point Microsoft will release an update (I hope) but until them we can just add in the appropriate MIME Types to our web servers and that should give us the results we want.
I put up the list of office 2007 file extensions and their MIME Types on to the server hosting my MediaWiki and just like that everything worked. Here is the list of Office 2007 MIME type associations you can add if you run into this same problem.
I am pretty new to this and am using Drupal. We uploaded a .xlsm file and when someone tries opening it, it opens in ZiP and the content is not what we uploaded.
I tried what was suggested however the .htaccess file already exists in the root.
What do you recommend? Should I append the existing file?
I actually tried that and restarted Apache but no-go...
Thank you,
Keep in mind, all I did was add to the file what was recommended (see below)
#
# Apache/PHP/Drupal settings:
#
# Protect files and directories from prying eyes.
<FilesMatch "(\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
Order allow,deny
</FilesMatch>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Follow symbolic links in this directory.
Options +FollowSymLinks
# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
# Enable expirations.
ExpiresActive On
# Cache all files for 2 weeks after access (A).
ExpiresDefault A1209600
# Do not cache dynamically generated pages.
ExpiresByType text/html A1
</IfModule>
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# If your site can be accessed both with and without the prefix www. you
# can use one of the following settings to force user to use only one option:
#
# If you want the site to be accessed WITH the www. only, adapt and
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
# RewriteRule .* http://www.example.com/ [L,R=301]
#
# If you want the site to be accessed only WITHOUT the www. prefix, adapt
# and uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule .* http://example.com/ [L,R=301]
# Modify the RewriteBase if you are using Drupal in a subdirectory and
# the rewrite rules are not working properly.
#RewriteBase /drupal
# Rewrite old-style URLs of the form 'node.php?id=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^id=([^&]+)$
#RewriteRule node.php index.php?q=node/view/%1 [L]
# Rewrite old-style URLs of the form 'module.php?mod=x'.
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
#RewriteRule module.php index.php?q=%1 [L]
# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
All that stuff was from the op in some kinda crazy format for some other web server that I'm too stupid to understand, my post was what you needed for Apache. All that garbage you put in there Apache has no idea what to do with.
i removed the extra stuff and restarted the server but that did not do it.
I added this script (not mine) and placed it: Apache Group\Apache2\conf\update_mime.vbs
and that seemed to have dome something however instead of downloading the .xlsm file as 07 it opens as 03.
Any other thoughts?
'This script adds the necessary Office 2007 MIME types to an IIS Server.
'To use this script, just double-click or execute it from a command line.
'Running this script multiple times results in multiple entries in the IIS MimeMap.
Dim MimeMapObj, MimeMapArray, MimeTypesToAddArray, WshShell, oExec
Const ADS_PROPERTY_UPDATE = 2
'Get the mimemap object
Set MimeMapObj = GetObject("IIS://LocalHost/MimeMap")
'Call AddMimeType for every pair of extension/MIME type
For counter = 0 to UBound(MimeTypesToAddArray) Step 2
AddMimeType MimeTypesToAddArray(counter), MimeTypesToAddArray(counter+1)
Next
'Create a Shell object
Set WshShell = CreateObject("WScript.Shell")
'Stop and Start the IIS Service
Set oExec = WshShell.Exec("net stop w3svc")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
Set oExec = WshShell.Exec("net start w3svc")
Do While oExec.Status = 0
WScript.Sleep 100
Loop
Set oExec = Nothing
'Report status to user
WScript.Echo "SharePoint Mime Types have been added."
'AddMimeType Sub
Sub AddMimeType (Ext, MType)
'Get the mappings from the MimeMap property.
MimeMapArray = MimeMapObj.GetEx("MimeMap")
' Add a new mapping.
i = UBound(MimeMapArray) + 1
Redim Preserve MimeMapArray(i)
Set MimeMapArray(i) = CreateObject("MimeMap")
MimeMapArray(i).Extension = Ext
MimeMapArray(i).MimeType = MType
MimeMapObj.PutEx ADS_PROPERTY_UPDATE, "MimeMap", MimeMapArray
MimeMapObj.SetInfo
End Sub
I am facing the same issue (office 2007 files are opened as zip files while downloaded). I am using Pramati 4.1 server. I do not see .htaccess in the server. Can you please help me how to fix this issue in Pramati.
I have half users using Mozilla with no problem but those using IE have the issue, I haven't seen any patch from Microsoft as a patch yet, but isn't this really an IE issue?
Hi, I have IIS 5.1 installed on my computer with windows xp pro (sp2). I use Coldfusion MX.
I have added the mime types to my IIS.
I've also added these mime types to the metabase.bin.
However, when i access my website (with IE7 )on localhost the problem still remains.
The office 2007 files are stll being downloaded as .zip files.
Any sugestions ???
This did it for me, thanks a lot mcupples, opened the folder my Excel file was in then went to file manager, created new file paste it the code you recommended, done.
Bookmarks