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
Leave a reply