panthro's avatar

How does storage work when accessing from public?

Here's my config:

 'public' => [
            'driver' => 'local',
            'root' => storage_path('app/public/uploads'),
            'url' => env('APP_URL').'/storage',
            'visibility' => 'public',
            'throw' => false,
        ],

My disk is set to this in the env. I have run php artisan storage:link.

When I upload an image it is stored under /storage/app/public/uploads/image.jpg.

I can access it from domain.localhost/storage/uploads/image.jpg and domain.localhost/uploads/image.jpg.

Why can it be accessed from two places?

Also - am I correct in thinking there is no physical file in the public directory as the directory is just linked?

0 likes
2 replies
Snapey's avatar
Snapey
Best Answer
Level 122

all requests for example.com/storage/. are resolved by the folder at project/storage/app/public because of the symlink

if you are getting the same file at the URL example.com/uploads then you have an extra symlink that should not be there

1 like

Please or to participate in this conversation.