Jump to content

donlizard

Members
  • Posts

    10
  • Joined

  • Last visited

Profile Information

  • Gender
    Male

donlizard's Achievements

Newbie

Newbie (1/5)

2

Reputation

  1. HI Guys, After pondering over the script I changed one small line and the script works great! Yaaaay! Thank You's and kudos go out to Psycho and Ansego for the code and suggestions for my issue, you guys are great! Donlizard
  2. What's happening now is that the script deletes the webcam.jpg in the images directory, but is not replacing it with one from the uploads directory and deleting the oldest ones. We're getting closer!!
  3. 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> <iframe src="http://www.cypresshills.com/procomm/images/webcam.jpg" width="640" height="360" frameborder="0" scrolling="no"> </iframe> </body> </html> Thanks!
  4. Hi Psycho, I understand everything you have showed and told me, thanx again. I setup the structure like you said, and the paths, unfortunately it is not working. If you go to this URL it will show you what's happening. http://www.cypresshills.com/procomm/ I've tried several different pathing methods, but alas I can't get it working. Thank you, Don
  5. 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 ....
  6. 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
  7. 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> <iframe src="http://www.blahblah.com/webcam.jpg" width="352" height="288" frameborder="0" scrolling="no"> </iframe> </body> </html> Thanks for your time, Donlizard
  8. 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
  9. Hi, The camera is ftping the images to the server. There is no code written for this yet. Thanks, donlizard
  10. 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.