I need an image in my index blade, but I've never done this in Laravel. I keep getting 404's back, when I try.

I've tried altering the route in the asset() function multiple times. Nothing seems to work.

                <img src="{{ asset('public/storage/img/wvzonline_logo.png') }}" alt="Het logo van WVZ.Online">

I ran the line down here too.

php artisan storage:link

At the moment I get 404's not found. What I want is the image displayed, of course.

2 Answers

1
thebrownkid On Best Solutions

First of all please do check if wvzonline_logo.png exists in the folder public/storage/img.

If yes, give this a try -> {{ asset('/storage/img/wvzonline_logo.png') }}

As the symlink is created successfully you can use the asset() to access the images in the storage folder.

0
Cloud Soh Jun Fu On

You don't need to prefix public in the asset path, if you do so, you would be accessing http://localhost/public/storage/image.png.

Your http://localhost is already in the public folder scope, so that you only have to access the storage via asset('storage/image.png'). Or you can use Storage::url('image.png') to get the path. However, note that the url is affected by the APP_URL in your .env.

app
config
database
public -|
  index.php
  storage -|
    image.png
storage
  app
    public
      image.png

The config/filesystems.php specified the path of your storage, and the url to access it. Client are unable to view the image unless you put it in the public folder (by php artisan storage:link, which symlinks your storage folder with public/storage).