0
votes

I have one page where everything works fine. I moved this page to another server (not localhost) but my symlink doesnt work. When I upload files, they are stored only in storage/app... but not in public/storage

When I delete folder: public/storage from local and also from server and run: php artisan storage:link it will write The "public/storage" directory already exists.

Also in routes I have Artisan::call('storage:link');

In env I have set FILESYSTEM_DRIVER=public

filesystem.php:

'disks' => [

    'local' => [
        'driver' => 'local',
        'root' => storage_path('app/public'),
        'permissions' => [
            'file' => [
                'public' => 0664,
                'private' => 0600,
            ],
            'dir' => [
                'public' => 0775,
                'private' => 0700,
            ],
        ],
    ],

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

view:

 <img src="{{ asset('storage/'.$image->full) }}" id="brandLogo" class="img-fluid" alt="img">

Code should be ok because at the other site I have the same code and it works. I have Laravel 5.8

Can you help me please?

1
just update your root in the public array to 'root' => 'storage'Joseph
and try to upload images again after edit itJoseph
is it secure to link it storage folder which is not in public folder?SHasdsd
i try alot to make the command storage:link in the server as you try but with nothing happenJoseph
'root' => 'storage': it created new folder in storage folder: storage/storage but didnt helpSHasdsd

1 Answers

1
votes

You can edit your root path in your public 'array' to be

'root' => 'storage'

but in this case, you can't use asset to print the path so you will be using url instead

so it would be like this

<img src="{{ url('storage/'. $image->full) }}">

about security, it's full secured if you try to go your storage from url like this

localhost/storage

it will give you access denied