3

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"'

            ));
Anshad Vattapoyil
  • 23,145
  • 18
  • 84
  • 132
Saravana Kumar
  • 816
  • 1
  • 12
  • 28

3 Answers3

0

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

icep87
  • 58
  • 3
0

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

AddType application/octet-stream .csv
Anshad Vattapoyil
  • 23,145
  • 18
  • 84
  • 132
0

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

Roshan
  • 521
  • 4
  • 16