DEV Community

webfuelcode
webfuelcode

Posted on

2 1

Laravel filesystems storage path

I personally stuck on the point where I created projects and forgot to change the path from storage to public. Actually, I wanted to store the file(images) in the image folder that was created in the root.

This is what we see in the filesystems.php file

'disks' => [

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

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

        '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'),
        ],

    ],
Enter fullscreen mode Exit fullscreen mode

Making your own way to stare the images. You can change the path by ...

'public' => [
            'driver' => 'local',
            'root' => storage_path('img'),
            'url' => env('APP_URL').'/img',
            'visibility' => 'public',
        ],
Enter fullscreen mode Exit fullscreen mode

In the 'root' => storage_path('img), You can change it like these

base_path();    // '/var/www/mysite'
app_path();     // '/var/www/mysite/app'
storage_path(); // '/var/www/mysite/storage'
Enter fullscreen mode Exit fullscreen mode

This post is just a help and it is available on StackOver: https://stackoverflow.com/questions/14631436/laravel-base-path

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay