Laravel - link to a file saved in storage folder

后端 未结 3 837
日久生厌
日久生厌 2020-12-17 02:45

When we do something like this:

Storage::disk(\'local\')->put(\'file.txt\', \'Contents\');

How do you make a link to that file in a view

3条回答
  •  心在旅途
    2020-12-17 03:20

    Scenario--(working from a fresh Laravel 5.6 project install for reference): With the existing default paths being /public and /storage/app/public and you want to physically store your logo.png image in the /storage folder and render it on your Welcome page, the process would go something like this:

    1. In your terminal, navigate to your Laravel project folder.
    2. Run command php artisan storage:link
    3. Now create the folder /images in your /storage/app/public folder which gives you /storage/app/public/images.
    4. Look in your /public folder and you will see the (shortcut) subfolders /storage/images
    5. Copy a test image named logo.png into the /storage/app/public/images folder.
    6. In your project's welcome.blade.php under /resources/views paste the following code over the existing code:

      Laravel
    7. Save and open your project in your browser and you should see the logo image.

    Having said all of that, later on you need a pdf folder to store uploaded pdf files. Easy, just create a new folder in /storage/app/public called /pdf and automatically the shortcut will appear in the /public folder. It is a once and "for all" solution.

提交回复
热议问题