[Opera browser] CI Download Helper downloads docx files as doc - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: [Opera browser] CI Download Helper downloads docx files as doc (/showthread.php?tid=60776) |
[Opera browser] CI Download Helper downloads docx files as doc - El Forum - 06-26-2014 [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/0ca6369333cd13dac201eb0585ce65ba 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. [Opera browser] CI Download Helper downloads docx files as doc - El Forum - 06-26-2014 [eluser]InsiteFX[/eluser] And were is the file name extension? [Opera browser] CI Download Helper downloads docx files as doc - El Forum - 06-26-2014 [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. |