Current Version: cavemonkey50’s Webcam Update Script 1.5
This PHP script will determine if a webcam image has been updated in a set amount of time. If it has been updated, it will display the webcam image; if it hasn’t it will display other content.
Installation
Open webcam.php with your favorite text editor and configure the variables at the top of the script. Then replace the three HTML spots with your specific HTML code.
Usage
Call the script within a PHP page with the following line of code:
<?php readfile("http://location.to/webcam.php"); ?>
Download cavemonkey50’s Webcam Update Script
Current Version: 1.5
Released: 2005-11-03
Download cavemonkey50’s Webcam Update Script 1.5
Version History
1.5 - Minor Update
- Updated script to be more user friendly.
1.0 - Initial Release
Sponsored: Live Web Cam Chatten Webcam chat

16 Comments
i try your script to view my webcam image but it doesn’t work.
please take a look at http://adrian.bahana.net/webcamimg.php (this is your script), the result is always offline.
my online webcam page can be found at http://adrian.bahana.net. click it to view refreshed webcam image (every 3 seconds) in a pop-up window.
fyi, i also wrote a tutorial about installing webcam in gnu/linux box (in bahasa Indonesia), please come to http://adrian.bahana.net/2005/09/07/instalasi-webcam-di-gnulinux/
sorry about my english.
Adrian, it appears that it’s working when I visit your site. Did you get it working or are you still having problems?
oops! sorry. it’s my false. your script is working well.
i forgot to set permission on the image directory.
thank you brother!
I have my site running on another server and my webcam is running on a computer at my home which uploads a webcam image every 30 seconds to the web folder on the computer. Now in directory field i put http://computersIP/ and the webcam image i put webcam.jpg and refresh at 70 seconds.
I tested the link to the webcam image and it works fine.
Now i haven’t made a webcam down page but looking at the source code for the html, it’s loading the offline page. Take a look for yourself http://coldcoloradan.com/webcam/webcam.php
Now is it possible to put a http:// link instead of the server directory since it’s on another server? For example
$file = “cavecam.jpg”; // The name of the image
$dir = “http://60.60.123.4/”; // The directory the image resides (using full server path)
$time = 60; // How long the webcam should be displayed before considered offline (in seconds)
Let Me know.. Thanks
No, it’s not possible for it to work on another server. The reasoning is PHP has no way to view when the image was updated on another server. It needs to be installed locally to retrieve file attributes.
However, the script can be called remotely. So, if you wanted to install PHP on your webcam server, and call the script from your site, that can be done.
How would i call the script remotely?
Actually is there a way just to see if the server is up or down.
For example if the server is up it would load the webcam up page
and if it’s down, it would load up the webcam down page on my website.
Pretty much my computer is on a scheduel to shut down at 10:30PM and start up at
5:00AM. Well in between those times i would like a script to see that the server is down and display the webcam down page.
Do you know any way of doing this?
hello!
Scripts looks fine but where i gave to put my IP number - where the web cam is - and it will give the pictures for the web-site?
Yes, in the section for an online webcam, just place the image HTML for your webcam.
Ronald,
Love your simple webcam update script. However, I need to display the latest image file in a series of files named with a time stamp, rather than the same filename. (Camera takes one pic every three minutes, always with a new file name.) I’m guessing that’s not too hard for someone who’s not as rusty at PHP as I am. Hint, hint…
Ken, I can point you in the right direction. You want to use the scandir function and grab the first item in the array. If you’re looking for more assistance, I am available for hire.
Hello,
I hate to be the only one in here that cannot figure out the script, however it looks like I am. I am not a coder of php or html other than the basics. That said, I have been unable to figure out what your script wants in the area the install directions say to edit in the webcam.php file where it says:
I have tried the which made sense but displays nothing with the script although the same line loads the image when used in the address bar of a browser. I am trying to use this with a wordpress site and get away from javascript that breaks on every Wordpress upgrade. I don’t need the exact code, just a little more direction than the others needed. This is needed to reload a .jpg file that updates every 10 seconds (simple webcam).
Thanks,
Jim
Hi,
What was stripped out of my first post was this. I do not understand what I am supposed to add where the instructions say.
“Then replace the three HTML spots with your specific HTML code.”
Adding img tags does nothing in the webcam.php file. They do not even show up when viewing the source code from the website. I just need some pointers.
Thanks,
Jim
Jim, if you’re trying to reload an image live on the page, this script isn’t for you. What this scrip does is display an offline indicator if your webcam stops broadcasting.
hey
can anyone give those 3 html codes (active,inactive,image does not exist)…atleast give me the suggestions, i am very much new to the coding…….i want to know the magic behind this code .
Please “cave monkey50″, “Adrian”….any one else
Can anyone show it in action?
One Trackback/Pingback
[...] Thanks to Jonathan, I got the bug to fix up cavemonkey50’s Webcam Update Script. I rearranged and simplified things, making it easier to edit for other’s needs. After working with the script for a little, I now deem the script ready for public release and I have created a page for it. [...]
Post a Comment