Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We have a php application, and xlsx files are getting downloaded as zip files.

I've seen many posts with solutions for handling this - with htaccess, httpd.cond, and mime.types files.

Our files our hosted though, and the host is giving us a hard time about chaging any server (apache on linux) files. He thinks we should do the fix in php.

So my question is:
What is the benefit (if there is one) of making the change in the server configuration files, rather than in php?

share|improve this question

2 Answers 2

Doing it in your PHP script is the best option, because you applications knows best what files it transmits and can set the MIME type header (Content-Type) accordingly.

share|improve this answer

In this instance the correct answer would be to set the Content-Type in your PHP. xlsx files are zip files and Apache is using file like identification in mod_mime_magic to figure out that this is a zip file and setting the mime type accordingly. If you run them through unzip you'll get a whole load of directories and XML files splattered everywhere.

As you need it to open in Excel, you should be overriding this default behaviour in your PHP.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.