I have images in my public
folder (NOT STORAGE) :
And I want to get all these files in a list and for each one, I do something ... How can I do that?
You could do this in one line:
use File;
$files = File::files(public_path());
// If you would like to retrieve a list of
// all files within a given directory including all sub-directories
$files = File::allFiles(public_path());
For more info, check the documentation.
Edit: The documentation is confusing. It seems, you would need to use the File
Facade instead. I will investigate a bit more, but it seems to be working now.
Also, the result will be an array of SplFileInfo objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With