gpt4 book ai didi

php - 如何在 laravel 中设置可下载文件的文件名?

转载 作者:行者123 更新时间:2023-12-02 15:10:20 26 4
gpt4 key购买 nike

您好,我想重命名一个可以从网站下载的文件。

这就是我填充响应的方式。

return response()->view('ordersxml.order-template',compact('order','debtor','today'))->header('Content-Type','text/xml')->header('Content-disposition','attachment')->header('filename','test');

->header('filename','test');

不工作。我做错了什么?

提前致谢

最佳答案

当然,您可以添加 header filename,但这是行不通的,因为正确的下载 header 是:

Content-Disposition: attachment; filename="filename.jpg"

所以,你的代码应该是:

return response()
->view('ordersxml.order-template',compact('order','debtor','today'))
->header('Content-Type','text/xml')
->header('Content-disposition','attachment; filename="test"'));

关于php - 如何在 laravel 中设置可下载文件的文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44517427/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com