【发布时间】:2019-07-31 14:55:55
【问题描述】:
我想下载一个文件,但每当我尝试下载它时,它都会显示此错误:
调用未定义的方法 Symfony\Component\HttpFoundation\BinaryFileResponse::header()
@if($document->file)
<td>
<a href="{{route('file.download',$document->file)}}"><button class="btn btn-xs btn-outline-warning">{{$document->file}}</button></a>
</td>
@endif
路线:
Route::get('/employee/file/download/{file}','ErpEmployeeController@fileDownload')->name('file.download');
控制器:
public function fileDownload($file)
{
$files = public_path() . "/uploads/file/" . $file;
return response()->file($files);
}
【问题讨论】:
-
如果你想下载你应该使用
response()->download($files);
标签: laravel