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

后端 未结 10 1023
陌清茗
陌清茗 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 11:08

    Since Laravel 5.2 you can use File Responses
    Basically you can call it like this:

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

    and it will display files as PDF and images inline in the browser.

提交回复
热议问题