Jump to content

donlizard

Members
  • Posts

    10
  • Joined

  • Last visited

Posts posted by donlizard

  1. Hi,

     

    Here is the code I used for my index.php. Its the same you gave me, with a small added part at the top.

     

     

    <?php
    ini_set('display_errors', 1);
    error_reporting(E_ALL ^ E_NOTICE);
    ?>
     
    <?php
     
    //Define locations for uploads and final file
    $path_to_uploads = "uploads/";
    $final_image  = "images/webcam.jpg"; //Path to save the most recent
     
    //Get the files in the upload directory
    $uploaded_files = glob("{$path_to_uploads}*");
    //Create var to detect recent files
    $recent_date = 0;
    //Iterate through all uploads
    foreach($uploaded_files as $file)
    {
        $file_date = filectime($file);
        //If file is newer, rename it else delete it
        if($recent_date < $file_date)
        {
            rename($recent_file, $final_image);
            $recent_date = $file_date;
        }
        else
        {
            unlink($file);
        }
    }
     
    ?>
     
    <html>
    <head>
    <title>Webcam Test</title>
    </head>
    <body>
    width="640" height="360" frameborder="0" scrolling="no">
    </iframe>
    </body>
    </html>
     
    Thanks!
  2. Hi Guys,

     

    I would assume I have the pathing correct, but it's doing nothing to the images.

     

    <?php
     
    //Define locations for uploads and final file
    $path_to_uploads = "./images";
    $final_image  = "./images/webcam.jpg"; //Path to save the most recent
     
    //Get the files in the upload directory
    $uploaded_files = glob("{$path_to_uploads}*");
    //Create var to detect recent files
    $recent_date = 0;
    //Iterate through all uploads
    foreach($uploaded_files as $file)
    {
        $file_date = filectime($file);
        //If file is newer, rename it else delete it
        if($recent_date < $file_date)
        {
            rename($recent_file, $final_image);
            $recent_date = $file_date;
        }
        else
        {
            unlink($file);
        }
    }
     
    ?>
     
    Hmmmm ....
  3. Thank you Psycho and Ansego!

     

    Your input has been great! The last time I was doing code like this was in 2006, so getting back into has been a bit of a learning curve.

    The upload directory for the images is one and the same, the images directory.

    I'll alter the php and html code and let you know, thanks again.

     

    Donlizard

  4. HI Psycho,

     

    You're right, the image will change every 5 or 15 minutes, it really doesn't matter, and yes it's not going to be a high traffic website.

    That's a great idea about access and renaming!

     

    Here's the code to show the image.

     

    <html>

    <head>
    <title>Webcam</title>
    </head>
    <body>
    width="352" height="288" frameborder="0" scrolling="no">
    </iframe>
    </body>
    </html>

     

    Thanks for your time,

    Donlizard

  5. Hi Ansego,

     

    Thank you so much for your input!

     

    I'm using the following script to delete all the files every 15 mins, and it works.

     

    <?php
    $dir = './images/';
    $days = 900; // 15 mins
    if($handle = opendir($dir)) {
     
        /* This is the correct way to loop over the directory. */
        while (false !== ($file = readdir($handle))) {
            if ( filemtime($dir.$file) <= time()-$days) {
               unlink($dir.$file);
            }
        }
     
        closedir($handle);
    }

     

     

    But I want the script to always leave behind the newest one so I can rename it.

    The customer is running a Joomla website so he wants to use an iframe, I would love to use a div, but this is what I have to contend with.

    Slowly but surely I guess ....

     

    Thanks,

    Donlizard

  6. Hi Everyone,

     

    I have literately been out of the game for a few years, but I'm now getting back into it.

    I have a webcam that FTP's an image up to a server. It's file name is Webcam20140314_160304_7717.jpg and so on.

    My goal is to rename the newest file to webcam.jpg according to date and time stamp and delete the rest.

    Then that image would be displayed in an iframe. The script would run every 15 minutes.

    Any suggestions?

    I know it's a lot to ask, but I just don't have a clue anymore.

     

    Thanks,

    Donlizard

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.