Laravel’s Storage facade makes it easier to get list of files within a directory. However if you are looking to get a list of files within the public directory, or any other directory within the public directory.
Here is how you can do this.
Open the file
filesystems.php located inside config directory. Make sure you have a disk that points to the public path of your application. If not go ahead and add the disk
'local' => [ 'driver' => 'local', 'root' => storage_path('app'), ], 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), 'url' => env('APP_URL').'/storage', 'visibility' => 'public', ], 'public-folder' => [ 'driver' => 'local', 'root' => public_path(), ],
Run config clear
php artisan config:clear
You can name the disk name as per your choice, I have given disk name as
public-folder for the demonstration.
Use coupon 5balloons on this Cloudways Affiliate URL to get special discount.
To get all the files in the public folder you can run
To get all the files in a folder inside public folder, you can run