I've looked at Pull all images from a specified directory and then display them and Pull all images from a specified directory and then display them. It seems like the solution that they provide on these posts are pretty straightforward. So I tried using the code but instead of an image, I get a string of the name of the image. And there are more than just one image in my uploads
folder, but it only shows the name of one image.
Just to give some context, in one folder, I have my index.html
, upload.php
and a directory called uploads
, where all my images are stored.
Here is the code that I have:
<body>
<div>
<a class="info" id="hvr-float" id="thePeopleButton" p style="font-size:30px" href="javascript:void(0);">The People</a>
<h1 class="infoText" style="display:none"></h1>
<?php
$directory = "uploads/";
$images = glob($directory."*.jpg");
foreach($images as $image)
{
echo '<img src="'.$image.'" /><br />';
}
?>
</div>
</body>
I would like the code to display image instead of just text. Here is a picture of what is happening on my website:
So, instead of uploads/awesome-fruit.jpg
, I would like the actual image there. Any suggestions?