【发布时间】:2018-12-13 19:07:07
【问题描述】:
我已将我的 pdf 文件存储在公用文件夹内的文件夹中。现在,我在 resources/views/admin/view_data.blade.php 中有一个“下载”按钮
当我点击下载按钮时如何下载pdf文件??
【问题讨论】:
我已将我的 pdf 文件存储在公用文件夹内的文件夹中。现在,我在 resources/views/admin/view_data.blade.php 中有一个“下载”按钮
当我点击下载按钮时如何下载pdf文件??
【问题讨论】:
只是一个小补充,如果您使用的是 IDE,以下内容将防止任何 squark
return response()->download($file, 'filename.pdf' ,$headers);
【讨论】:
试试这个。 当您单击按钮调用路由和方法时,然后使用此代码。您可以更改目录路径。
public function getDownload()
{
//PDF file is stored under project/public/download/info.pdf
$file= public_path(). "/download/info.pdf";
$headers = array(
'Content-Type: application/pdf',
);
return Response::download($file, 'filename.pdf', $headers);
}
【讨论】: