N
N
nickname68472019-09-16 11:59:20
Laravel
nickname6847, 2019-09-16 11:59:20

How to display all the images that are in the public / img folder?

For example, this is how we display some kind of data array:

foreach( $posts as $post )
{
    echo $post->body;
}

And how to display on the page all the images that are in the folder public/imgin the same way? There are svg and png images. Or is there something in Laravel for that? I did not find...(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nickname6847, 2019-09-16
@nickname6847

Found the answer:

use Illuminate\Support\Facades\Storage;
$files = Storage::files($directory);
$files = Storage::allFiles($directory);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question