We help IT Professionals succeed at work.

Display recently uploaded images

I am currently working with a web server that has a directory containing images that are uploaded chronologically from a webcam.  My end goal is to have a web page that displays the three most recent images uploaded.  I have attempted to do this with the following code:

$files = glob("imageDirectory/*.*");
for ($i=3; $i<count($files); $i++)
	$num = $files[$i];
	print $num."<br />";
	echo '<img height="450px" width="800px" src="'.$num.'" alt="random image" />'."<br /><br />";

Open in new window

However instead of displaying three recent images, it shows all of them.  Any advice would be greatly appreciated!
Watch Question

Whoops, just caught the issue with my for loop.  Fixed.


For loop problem.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.