Display most recent image in folder, refreshing automatically
<p>I have a webcam that uploads a photo about every 30 seconds to a specific folder via FTP.  The files are named using the date and time they were created.</p>

<p>For example the image "image20161023s131200029.jpg" will have been created on the 23/10/2016, at 13:12:00.  The way the images are named cannot be changed.  The next image will be uploaded about 30 seconds later, but not exactly so it is not possible to predict the next file name.</p>

<p>I wish to display the most recent image and refresh this every 30 seconds.</p>

<p>My problem is that I can display the most recent image in php, using scandir() and sort() to get the most recent image, but as this is in PHP it cannot be refreshed.  I could also use JavaScript to referesh an image at a given interval if the location was always the same, so if the most recent image was always at "/webcam/webcam01.jpg" then this would be fine.  However I am not sure how to do this when the image name will constantly be changing, if anyone knows the best (or atleast a working) way to do this that would be fantastic.</p>

<p>I hope that I have been clear about what I am trying to do, sorry if this has been answered before - I have tried both this sites search and google to no avail.</p>