[Opera browser] CI Download Helper downloads docx files as doc |
[eluser]Bikun[/eluser]
Hello, By some reason in Opera browser CI Download Helper function force_download('filename', 'data') pushes docx files as doc. When I try to download docx file directly, everything works well. Here is a link to a Word file, downloaded via CI Download Helper: http://www.tekstiabi.ee/et/download/0ca6...0585ce65ba Here is a direct link to the same file: http://www.tekstiabi.ee/uploads/tolge.docx Here is a code what I use: Code: $this->load->helper('download'); The problem exists only in Opera browser. Any idea what could be wrong? Thanks in advance.
[eluser]Bikun[/eluser]
Hi, Just found a solution myself. Basically, I checked what headers are returned in case of direct and indirect download. Direct download: Code: Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document Indirect download: Code: Content-Type: "application/msword" Then checked how this content-type is created in helpers/download_helper: Code: // Set a default mime if we can't find it Then checked my mimes.php for docx extension: Code: 'docx' => array('application/msword', 'application/zip', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'text/plain', 'application/x-zip'), Since download_helper takes the first element in the array, replaced 'application/msword' with 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', so resulting line is: Code: 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/octet-stream', 'application/msword', 'text/plain', 'application/x-zip'), Now files are downloaded with correct type. Problem solved. |
Welcome Guest, Not a member yet? Register Sign In |