Internet Explorer saves Office 2007 files as .zip downloaded from Apache web server
This falls into category - If It Weren’t So Sad It Would Be Funny. Well the other day, I was making dynamic pricelist generator for elkotech.hr webshop. User logs in, generates Excel (.xlsx) pricelist with his own discounts and stuff and downloads it. Except for slow Excel 2007 worksheet creation with php code, everything is pretty straight forward.
After I deployed the stuff on production server, clients calls me up and says - "Hey, what kind of zip file did you create? It's full of strange xml files!". Doh! What zip? Scratch...Scratch... What browser do you use? Aha.. Internet Explorer. :)
The thing is - since Apache doesn't come out of the box with mime handlers for "new" Office 2007 formats (.docx, .xslx ...), he sends that .xlsx file as Content-Type: text/plain. Internet Explorer (6,7,8) tries to be smart and figures out that .xlsx is nothing more than zip file containing lots of xml files, and therfor offers user to save that document as .zip file. Rendering my beautiful pricelist useless in the process.
The workaround is simple - just add this to your .htaccess file (or appropriate Apache config file to which you have access)
AddType application/vnd.openxmlformats .docx .pptx .xlsx
After that, files with those extensions will be served with correct content type - Content-Type: application/vnd.openxmlformats.
Alternatively, you could deliver the files on your own trough php's fpassthru and add appropriate heders by your self, but fpassthru is slow as hell.