Laravel下载不起作用

时间:2016-08-09 06:11:04

标签: php laravel laravel-5.2

我正在尝试下载数据但由于某种原因它无法正常工作

查看

@foreach($files as $file)

  {!! Html::link('public/'.$file->name, $file->name) !!}

@endforeach

控制器

public function download($file_name){
    $file_path = public_path('/'.$file_name);
    return response()->download($file_path);
}

路线

Route::get('download/{file}','FilesController@download');

我收到此错误

NotFoundHttpException in RouteCollection.php line 161

in RouteCollection.php line 161
at RouteCollection->match(object(Request)) in Router.php line 821
at Router->findRoute(object(Request)) in Router.php line 691

1 个答案:

答案 0 :(得分:2)

路径错误,您正在观察/download/{file}但是正在调用/public/{file}

{!! Html::link('download/'.$file->name, $file->name) !!}