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?
Advertisement
Answer
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.