In this article, i will guide you how to get all files in public directory with laravel 6 application. we can easily get files from folder using File or Storage facade in laravel 6 project. i will give you simple and more solution of laravel 6 get files from public folder or storage folder.
I will give you more way to get files list in public folder in laravel 6. you can see i will use File facade to get files list, Storage facade will use to get files list in directory from storage in laravel 6 and also i will give you simple code core php to get files list in folder.
Using File System 1:
public function getFiles(Request $request)
{
$path = public_path('upload/itsolutionstuff.com');
$files = File::files($path);
dd($files);
}
Using File System 2:
public function getFiles(Request $request)
{
$path = public_path('upload/itsolutionstuff.com');
$files = File::allfiles($path);
dd($files);
}
Using Storage System:
public function getFiles()
{
$path = public_path('upload/itsolutionstuff.com');
$files = Storage::files('upload/itsolutionstuff.com');
dd($files);
}
Using Storage System 2:
public function getFiles()
{
$path = public_path('upload/itsolutionstuff.com');
$files = Storage::allfiles('upload/itsolutionstuff.com');
dd($files);
}
It will help you...
Do you like below Tutorials ?
- PHP Laravel 5.5 - import export data into excel and csv using maatwebsite
- Laravel 7.x and 6.x create custom facade example from scratch
- Node JS - Get Real time online users counter using socket io example
- PHP Laravel 7.x and 6.x - Bootstrap Admin Theme Integration example from scratch
- MySQL Query - How to select records of today to next Sunday ?
- Laravel 7.x and 6.x - username custom validation example
- Laravel 5.5 - Import Extract zip file using chumper/zipper package
- PHP Laravel Set Custom Validation Error Messages Example