VertexBuffer's avatar

Help with getting FileSystem working?

I've tried following so many guides and reading the docs over and over again, and it simply doesn't make any sense.

My end goal is to make it so that I can upload my images into; /public/images and will produce the url; valet.test/images/<image_hash>.

The problem is, even after setting up my own FileSystem like so;

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

The files constantly keep uploading to; /storage/app/images and I have no clue why.

Hopefully someone can explain.

I've already run the symlink command so I don't think that's it.

0 likes
2 replies
Braunson's avatar

Your using storage_path() helper in your root. This literally uses /storage + whatever you have inside the ().

What you would want is public_path instead of storage_path. However I don't recommend doing it that way. Instead follow the doc's suggested method.

Upload to the storage path, and then symlink your storage folder to public.

The public disk is intended for files that are going to be publicly accessible. By default, the public disk uses the local driver and stores these files in storage/app/public. To make them accessible from the web, you should create a symbolic link from public/storage to storage/app/public. This convention will keep your publicly accessible files in one directory that can be easily shared across deployments when using zero down-time deployment systems like Envoyer.

Check this out on how to symlink storage to public and how to use the asset() helper https://laravel.com/docs/5.8/filesystem#the-public-disk

VertexBuffer's avatar

@braunson

"Your using storage_path() helper in your root. This literally uses /storage + whatever you have inside the ()." That isn't me doing it, I literally just duplicated the public default and changed it to have a subfolder of images inside of it.

However, even then something still isn't correct. If it's suppose to be /storage + whatever you have inside the ()., that isn't working either. Because that means I should have a folder inside public called images, but instead I'm getting a folder called images NEXT to the public folder.

I've already tried using the way the docs talk about with symlinking and such, and if I use the default public driver, it works. BUT, I don't want to use the default public driver. I want to have an images folder INSIDE of public that they are stored so that it keeps things more organised!

Hopefully that helps clarify things a little better.

Please or to participate in this conversation.