2
votes

I try to return file download response in laravel with custom content type, the response content type comes as text/html to browser in localhost. Whereas it works fine in the server machine code. It makes debugging harder.

Is it anything to do with apache server config?

Below is the laravel code used.

return Response::download($filepath, $filename.'_questionaire.csv', array(

            'Content-Type'              => 'text/csv',
            'Content-Disposition'       => 'attachment;filename="'.$filename.'._questionaire.csv"'

            ));
3

3 Answers

0
votes

To force your browser to download CSV files you can add this in the .htaccess file:

AddType application/octet-stream csv

You could also check out:

http://www.thingy-ma-jig.co.uk/blog/06-08-2007/force-a-pdf-to-download

0
votes

Add the below line to apache's httpd.conf in <IfModule mime_module> block

AddType application/octet-stream .csv
0
votes

The above answers are not working any guess why... I added AddType application/octet-stream csv at the .htaccess file located at the site public folder @ mamp/htdocs/website/public but still no success