Laravel 5文件下载无效 [英] Laravel 5 file downloads invalid

查看:215
本文介绍了Laravel 5文件下载无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Response::download下载文件时,我注意到图像和其他二进制文件传输不正确.

When using Response::download to download files, I noticed that images and other binary files were being transferred incorrectly.

更改Content-Type标头没有任何改变,也没有明确禁止缓存或强制内容的长度.

Changing the Content-Type header didn't change anything, nor did explicitly disallowing cache or forcing the content's length.

此问题可能是什么原因?

What may be the cause of this problem?

推荐答案

此问题的解决方案可以在这里找到:

The solution to this problem can be found here:

http://simpledeveloper.com/how-to-fix- laravel-response-image-download-in-laravel/

问题的原因是由于Laravel/Symfony由于某些原因未正确清理输出缓冲区,因此解决方案是这样的:

The cause of the issue was due to Laravel/Symfony not properly cleaning the output buffer for some reason, so the solution is this:

$response = Response::download($path, ...);
ob_end_clean();

return $response;

这篇关于Laravel 5文件下载无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆