Laravel文件下载响应的内容类型为localhost中的text/html [英] Laravel file download response content type is text/html in localhost
问题描述
我尝试使用自定义内容类型在laravel中返回文件下载响应,响应内容类型以text/html的形式出现在本地主机的浏览器中.而在服务器机器代码中它可以正常工作.它使调试更加困难.
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.
与apache服务器配置有关系吗?
Is it anything to do with apache server config?
下面是使用的laravel代码.
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"'
));
推荐答案
上面的答案无法正常工作,为什么...我在位于站点公用文件夹@的.htaccess文件中添加了AddType application/octet-stream csv. mamp/htdocs/website/public,但仍然没有成功
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
这篇关于Laravel文件下载响应的内容类型为localhost中的text/html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!