« Searching terminal history on Ubuntu | Main | Upgrading to D7? »
February 21, 2012
How to force browsers to download a csv file
1) Open the .htaccess file found in the core drupal installation
2) Add this line
AddType application/octet-stream .csv
--------------------------------------------------------------------------
UPDATE
I believe I have solved this. It appears you can either set "DefaultType application/octet-stream" or enable the mime_magic module. Recommendations or opinions on these approaches are welcome. Notes follow.
-------------------------------------------
Modify .htaccess
Source:
http://helpful.knobs-dials.com/index.php/Apache_config_and_.htaccess_-_semi-sorted
http://hints.macworld.com/article.php?story=20040211102018600
Add:
DefaultType application/octet-stream
-------------------------
Modify apache2.conf
/etc/apache2/apache2.conf
Source:
http://hints.macworld.com/article.php?story=20040211102018600
change:
DefaultType text/plain
to:
DefaultType application/octet-stream
Restart apache
-------------------------------
Modify httpd.conf
/etc/apache2/httpd.conf
Add:
DefaultType application/octet-stream
Restart apache
--------------
Enable mime_magic
Sources:
http://www.wellho.net/mouth/1564_Default-file-MiMe-types-for-Apache-httpd-and-Apache-Tomcat.html
http://httpd.apache.org/docs/1.3/mod/mod_mime.html
Enable mime_magic
$ sudo a2enmod
-> mime_magic
$ sudo /etc/init.d/apache2 restart
Disable a module:
$ sudo a2dismod
-> mime_magic
$ sudo /etc/init.d/apache2 restart
Posted by kkwaiser at February 21, 2012 01:03 PM