Problem with accessing local symbolic link in storage

Published 11 months ago by JanakaDombawela

Hi,

I created my symbolic link with php artisan storage:link

I save my files in following function:

Storage::put( Carbon::now()->format( 'Y' ) . '/' . Carbon::now()->format( 'm' ), 'file.txt' );

My config/filesystems.php configurations:

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

The files are saved in the storage/uploads/2017/10 directory, which is what I want.

I access them as follows:

{{URL::to('storage/2017/10/file.txt')}}

which outputs: http://localhost/mysite/public/storage/2017/10/file.txt and it gives 404.

When I try to enter http://localhost/mysite/public/storage it shows empty directory, not a 404.

Can you guys give any suggestions or ideas? Help is appreciated. Thanks.

Dry7
Dry7
11 months ago (151,880 XP)

@JanakaDombawela try

{{ Storage::url('2017/10/file.txt') }}}
JanakaDombawela

@Dry7 This outputs: /storage/2017/10/file.txt but still 404 :(

Snapey
Snapey
11 months ago (995,105 XP)

the symbolic link command makes a link to storage/public so you should put your files there (or in a subfolder) or make an additional symbolic link

Please sign in or create an account to participate in this conversation.