luisferfranco's avatar

Image saved doesn't display when recalled

Hello, I'm using Laravel 8. I'm storing images using Livewire in the controller like this:

if ($request->file('imagen_file')) {
  $filename = Storage::disk('public')->put('ranker', $request->file('imagen_file'));
  $ranker->imagen_url = $filename;
  $ranker->save();
}

This actually stores the images in \storage\app\public\ranker\ directory, this works perfectly in my dev environment (Windows). Then I retrieve the images in a blade file with:

          <img
            src="{{ Storage::disk('public')->url($o->imagen_url) }}"
            class="object-cover object-center w-32 h-32"
          >

$o is an object that comes from a @foreach. Again, this wotks perfectly in my development environment.

Now, when I upload this to my production evironment (Linux), the first part works fine, it stores the images where it should. But when I recall the images, the src expands to http://domain/storage/ranker/xxxxxxxxxxxx.jpg which should be correct, but returns a 404.

I've looking all around and find no answers. I thought it may have to do with permissions, I don't create the linux directories to upload, but Laravel does, I checked them public is 770, the ranker directory is 755 and the individual files are 644. So they should be readable by anyone right?

I really don't know what else to look for, my code seems to be alright

0 likes
2 replies
MohamedTammam's avatar
Level 51

Did you run the following?

php artisan storage:link
1 like

Please or to participate in this conversation.