在Laravel 5.5中强制下载PDF

时间:2017-10-30 15:46:22

标签: php laravel-5 download

在页面上,我有一个链接:

<a href="{{ route('downloadWirebird',[$mag->id]) }}" target="_blank" title="download PDF">@fa('download')</a>&nbsp;&nbsp;

在web.php中我有:

Route::get('downloadWirebird/{id}','FrontController@downloadWirebird')->name('downloadWirebird');

在FrontController中,我有:

public function downloadWirebird($id)
                {
                  $wbd = Wirebird::find($id);
                  $fileName = asset('Wirebird')."/".$wbd->PDF;
                  $headers = ['Content-Type: application/pdf'];
                  return response()->download($fileName, $headers);
                }

所有路径都是正确的,但是当我点击链接时,绝对没有任何反应。

0 个答案:

没有答案