Results 1 to 3 of 3

Thread: Display the last uploaded image on a page

  1. #1
    Join Date
    Jun 2013
    New Zealand

    Display the last uploaded image on a page

    We have a camera which uploads images to our webserver every 15 seconds. This static image is displayed on a page, and refreshed to show the latest image. This is uploaded as "webcam.jpg".

    I'd like to change the upload such that it uploads a set number of images. This will up upload images as "webcam1_1.jpg" through to "webcam1_480.jpg".
    Once 480 is uploaded, it resets to 1.
    Ultimately I aim to wrap all 480 images into an 60 second loop of the previous 2 hours captured.

    Is it possible to determine the newest image uploaded to the webserver and display this image each 15 second refresh?
    For example if the latest image is webcam1_178, this image is displayed on the page. When next checked, it finds webcam1_179 and displays this image.
    Date modified on the image includes the date and time uploaded.

    I don't use PHP, but that's the language our webserver needs so I appreciate any help!

  2. #2
    Join Date
    Nov 2003
    Worthington, OH, USA
    Easiest way would be to read the directory information into an array and sort on the modification date/time.

    Something close to:
    PHP Code:
    $files = array();
    if (
    $handle opendir('.')) {
    while (
    false !== ($file readdir($handle))) {
           if (
    $file != "." && $file != "..") {
    $files[filemtime($file)] = $file;

    // sort
    // find the last modification
    $reallyLastModified end($files);

    $files as $file) {
    $lastModified date('F d Y, H:i:s',filemtime($file));
    strlen($file)-strpos($file,".swf")== 4){
            if (
    $file == $reallyLastModified) {
    // do stuff for the real last modified file

    54 68 65 42 65 61 72 4D 61 79

  3. #3
    Join Date
    Jun 2013
    New Zealand
    Thanks for the quick reply!
    How do I add the directory the images are in for the array?
    The images are all .jpg, should the ($file,".swf") in the foreach be .jpg?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center