Laravel - display a PDF file in storage without forcing download?

后端 未结 10 1041
陌清茗
陌清茗 2020-12-02 10:31

I have a PDF file stored in app/storage/, and I want authenticated users to be able to view this file. I know that I can make them download it using

return          


        
10条回答
  •  没有蜡笔的小新
    2020-12-02 10:59

    As of laravel 5.5 if the file is stored on a remote storage

    return Storage::response($path_to_file);
    

    or if it's locally stored you can also use

    return response()->file($path_to_file);
    

    I would recommend using the Storage facade.

提交回复
热议问题