zenith707's avatar

Unable to access image url from storage

I am using Spatie's Media Library to handle uploads. Images are uploading to the media table correctly.

I have also set up a storage link for public/storage/ and storage/app/public/

My disks array in filesystems is:

'disks' => [
        'local' => [
            'driver' => 'local',
            'root' => storage_path('app'),
            'throw' => false,
        ],

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

        's3' => [
            'driver' => 's3',
            'key' => env('AWS_ACCESS_KEY_ID'),
            'secret' => env('AWS_SECRET_ACCESS_KEY'),
            'region' => env('AWS_DEFAULT_REGION'),
            'bucket' => env('AWS_BUCKET'),
            'url' => env('AWS_URL'),
            'endpoint' => env('AWS_ENDPOINT'),
            'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false),
            'throw' => false,
        ],
    ],

Within the storage folders the id of the upload is creating a folder so my paths end up being something like:

public/storage/7/image.png & storage/app/public/7/image.png or public/storage/8/image.png & storage/app/public/8/image.png

But my url's are always generating 404. http://localhost/public/storage/11/image.png // 404

Any help appreciated!

0 likes
1 reply
Sinnbeck's avatar

How are you using them? The word public should never be in your url. Is that word stored in the database as the path?

Please or to participate in this conversation.