如何显示已经上传laravel 5.2的文件?

How to display file which had already upload laravel 5.2?

我将文件上传到我的数据库,并将该文件作为同名文件移动到 documents 文件夹中的根路径中,如下所示:)

public function store(PslCall $call,Request $request)
    {
        $this->validate($request, $this->rules);
        $uploadDestinationPath = base_path() . '/documents/';
        $current_id = Document::where('call_id',$call->id)->count()+1;
        if ($request->hasFile('file'))
        {
            $file =$request->file;
            $fileName = $file->getClientOriginalName();
            $file->move($uploadDestinationPath, $call->id.'_'.$current_id.'_'.$fileName);
        }
        $input = $request->all();
        $input['file'] = $call->id.'_'.$current_id.'_'.$fileName;
        $input['call_id'] = $call->id;
        Auth::user()->documents()->create($input);
        return Redirect::route('calls.documents.index',$call->id)->with('message','You have successfully submitted');
    }

它的工作完美现在我在我的索引页面中显示如下所有文件:)

<td>{{strtoupper($document->title)}}</td>
<td><a href="{{ url('documents/'.$document->file) }}" target="_blank">{{$document->file}}</a></td>

现在我的路由文件我有路由来显示我的文件:

Route::get('documents/{file}',function() {
  return 'hi';
});

这里我点击时得到高输出 <td><a href="{{ url('documents/'.$document->file) }}" target="_blank">{{$document->file}}</a></td> this path

但我想知道如何显示我上传的相同文件名的文件?

As documentation says 如果你想显示文件内容那么你可以在你的路由函数中使用像这样的东西:

return response()->file('pathToFile');

如果下载文件是你想要的,那么尝试使用:

return response()->download('pathToFile');