Latest

Thursday, July 6, 2017

Change default "symbolic link" folder in laravel 5.4 (storage folder)

Asked by: twis


I'm making a new version of my site with laravel 5.4 and want to keep the same links than my old site has.

My old site has links images like this: domain.com/uploaded/cat.jpg

In laravel, its necesary to create a symbolic link to show the stored images but it saved them with a default folder named storage", like this: domain.com/storage/cat.jpg

How can i change the default name to "uploaded" or whatever?

I tried to change url inside the file \config\filesystems.php with this:

Before

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

After

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

and my controller

$request->file('image')->storeAs('public', 'example.jpg');


Source

No comments:

Post a Comment

Adbox