Reputation: 571
I want to show all images that are in a particular folder, I have the folder path but I do not see how the number of images there are inside and how show all. Someone could help me?
Upvotes: 0
Views: 1245
Reputation: 87799
If your files are inside public or a subfolder of it, this is is a way:
foreach (File::allFiles(public_path().'/assets/img/') as $file)
{
$filename = $file->getRelativePathName();
echo HTML::image('public/assets/img/'.$filename, $filename);
}
This is a router you can use to test it:
Route::any('images', function() {
$images = '';
foreach (File::allFiles(public_path() . '/assets/img/') as $file)
{
$filename = $file->getRelativePathName();
$images .= HTML::image('public/assets/img/'.$filename, $filename);
}
return "<htm><body>$images</body></htm>";
});
Edit the /assets/img/
to your own and just hit http://yourserver.dev/images
.
Upvotes: 3