The picture from storage is not displayed. I made a link to the public folder using the php artisan storage:link command and uploaded a picture there. The picture is not displayed in the template.

 <img class="card-img-top" src="{{URL::asset('/storage/123.jpeg')}}" alt="Card"> 

When copying a picture just to the public folder, the same picture is displayed correctly:

 <img class="card-img-top" src="{{URL::asset('/123.jpeg')}}" alt="Card"> 

Why can not I access the image in / public / storage?

  • {{Storage::disk('local')->url('123.jpeg')}} - Anton Kucenko
  • <img class="card-img-top" src="https://localhost/storage/123.jpeg" alt="Card image cap"> link still does not work, the picture is not displayed - Viktor
  • The project is deployed on docker-containers, perhaps a problem in the configuration ... - Viktor
  • github.com/spatie/laravel-medialibrary here I advise you to use a ready-made library. - Watscho Aiwasov

3 answers 3

Generate the link as follows ... according to the documentation https://laravel.com/docs/5.2/helpers#method-asset

 $url = asset('storage/123.jpeg'); 

or https://laravel.com/docs/master/filesystem#retrieving-files

 use Illuminate\Support\Facades\Storage; $url = Storage::url('storage/123.jpg'); 
  • laravel.com/docs/master/filesystem - $ url = Storage :: url ('file.jpg'); - n.osennij
  • I generate according to the documentation, but for some reason access to the picture is closed. I have already tried everything ... Result: <img class = "card-img-top" src = "/ storage / 123.jpeg" alt = "Card image cap">. The link is there, but not displayed. - Viktor

The picture should be in storage / public

To get a link to an image, use

 {{ asset('storage/image.jpg') }} 

If it does not work, check the link operability. For example, when cloning from a repository, the link turns into an empty folder

  • <img class = "card-img-top" src = " localhost / storage / 123.jpeg " alt = "Card image cap"> everything is the same. There is a link, but it is not displayed - Viktor

Solved a problem. Forgot to specify in a question that I use docker. Since the laravel project is spinning on docker containers, you need to create a link to storage from under the container, that is:

  1. Go to the web server container

    docker exec -it <container_name> / bin / bash

  2. Here we create a link using full paths.

    ln -s / var / www / html / storage / app / public / var / www / html / public / storage

And everything works, but the link outside the docker-container is defined as broken. Thanks to everyone who answered.