微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Laravel 图像未在浏览器中下载

如何解决Laravel 图像未在浏览器中下载

我的代码有什么问题? 当我在浏览器的检查元素中观看预览时,我可以在预览部分看到图像。但图片没有下载。

    $name = $result['name'];
    $path = $result['path'];
    
    $disposition = HeaderUtils::makedisposition(ResponseHeaderBag::disPOSITION_ATTACHMENT,$name,str_replace('%','',Str::ascii($name)));

    return \Response::download($path,[
        'Content-Type' => 'image/png','Content-disposition' => $disposition
    ]);

浏览器响应标头在这里

Accept-Ranges: none
Cache-Control: public
Connection: close
Content-disposition: attachment; filename=e7853e60982911eb912b2192bf4aa5360341.png
Content-Length: 5095
Content-Type: image/png

this is the sample image response in web browser

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。