PHP - Opening uploaded DOCX files with the correct MIME TYPE

Posted by user270797 on Stack Overflow See other posts from Stack Overflow or by user270797
Published on 2010-02-17T06:24:34Z Indexed on 2010/05/20 2:10 UTC
Read the original article Hit count: 379

Filed under:
|
|
|

I have users uploading DOCX files which I make available for download. The issues we have been experiencing is the unknown mime types of DOCX files which causes IE to open these docs as Zip files.

It is running on a Windows/IIS server.

Because this is a shared host, I cannot change any server settings.

I was thinking that I could just write some code that would handle DOCX files, perhaps custom output:

if (extension=docx) {

header("Content-Disposition: attachment; etc) header('Content-Type: application/application/vnd.openxmlformats-officedocument.wordprocessingml.document');

Output the file contents etc

}

Would this be a viable solution?? If so, can someone help fill in the gaps?

(PS I know the above syntax is not correct, just a quick example)

© Stack Overflow or respective owner

Related posts about php

Related posts about docx