Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

r2-dev's avatar

I can't retrieve files from storage

I am using Livewire to upload files and working fine. The next line do the job:

$url_photo = $this->photo->store('photos','public');

The file was saved on "storage/app/public/photos", i get that info from $url_photo. But when i try to get the file back, i get a 404 response.

$this->profile_pic = $url_photo; // the url = photos/h0njfN6ve7G2dWASdWUWgbzHgoB52CK8szM49qWl.png

in blade : img src=" / {{ $profile_pic }} "

i already did "php artisan storage:link" and remove /storage/app/public from .gitignore

Locally just add "storage " to the url and works, like this

$this->profile_pic = "storage/photos/h0njfN6ve7G2dWASdWUWgbzHgoB52CK8szM49qWl.png"

But in Production fails miserably. I am using forge to deploy to digitalOcean,

any idea? what i'm doing wrong

0 likes
4 replies
Snapey's avatar

and remove /storage/app/public from .gitignore

don't do this unless you want all your testing images stored in your code repository

in blade you need

 img src="{{asset('storage/' . $profile_pic }}"
			
1 like
r2-dev's avatar

Hey Snapey, I appreciate the advice. I made the changes you suggested but it still doesn't work. As I told you yesterday, locally everything is fine but not in production.

The thing is like this, when i upload the file with LiveWire it saves the file in the following path:

~mi-site /storage/app/public/photos

When i list the directory i can see the file uploaded

forge@contact:~/mi-site/storage/app/public/photos
   36dosjkFMQzss.jpg
   90DSxxlsk198xA.jpg
   ...

In blade I wrote:

<img class="profile--avatar " src=  "{{asset('storage/' . $profile_pic) }}" >  

Then in chrome the image is not seen, it appears broken (404 Not Found). The link that returns is

https://mi-site/storage/photos/90DSxxlsk198xA.jpeg

Seems to take the value of storage literally. I'm starting to think that "symlink storage" doesn't work. thanks in advance

Kumaravel's avatar
Level 2

Go to your public folder on the base directory and delete the existing storage shortcut file created previously. Then run the php artisan storage:link again. This will do the trick!

2 likes
r2-dev's avatar

KUMARAVEL in fact that did the magic. Thhnks!!!

1 like

Please or to participate in this conversation.