I am building a website where people can go and upload images, gifs, and videos. On the home page, I want to list files at random from the upload directory.
<article class="item thumb" data-width="384">
<h2><?php echo $file_title;?></h2>
<a href="<?php echo $randomImage ?>"><img src="<?php echo $randomImage ?>" alt=""></a>
</article>
<article class="item thumb" data-width="274">
<h2><?php echo $file_title;?></h2>
<a href="<?php echo $randomImage ?>"><img src="<?php echo $randomImage ?>" alt=""></a>
</article>
And it does that for a total of five times. $randomImage is generated from the code:
<?php
$imagesDir = 'uploads/';
$images = glob($imagesDir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
$randomImage = $images[array_rand($images)];
$file_title = $randomImage;
?>
I want to be able to add a feature to where as the user scrolls down, more and more of these articles containing images show up, each containing a random but not previously shown file. How can I display files at random without having to manually enter unique variables?
P.S. Right now I do not have any files stored in a database.