【发布时间】:2018-02-23 11:13:18
【问题描述】:
我想在下载之前设置标题。
在我以前用普通的 php 做这样的事情之前:
header('Content-Description: File Transfer');
header('Content-Type: application/pdf');
header('Content-Disposition: attachment; filename="'.basename($path).'"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($path));
readfile($path);
现在我希望仍然能够设置相同的标头并调用 laravel 下载函数并传递我的标头,例如:
return response()->download($pathToFile, $name, $headers);
$headers 变量应该包含我的标题。任何曾经这样做过的人。
【问题讨论】: