Posts Learn Components Snippets Categories Tags Tools About
/

How to Add public_uploads Path in Laravel “filesystems.php” config

Get to know how to add public_uploads path in Laravel filesystem PHP config to get the public path instead of the storage path

Created on Jan 25, 2022

218 views

In this short snippet, you will learn how to add a public_uploads path as a "disk" option which will allow you to get the files which is located in the "public" directory.
To set that up all you have to do is define a new configuration like below and it's how it works. 
<?php // filesystems.php

'public_uploads' => [
    'driver' => 'local',
    'root'   => public_path(),
],
And now you can access the disk as follows "disk('public_uploads')".
<?php

\Storage::disk('public_uploads')->url('some-file.png');
The path that it will generate will be something like (let's take example.test as the local domain then the output will be as follows):
https://example.test/some-file.png
Instead of:
https://example.test/storage/some-file.png

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️

)