HDTuto.com

Laravel 6 get all files in directory example



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...




September 28, 2019 | Category : LaravelLaravel 6
Related Posts



Blog Search