Browser is uploading JPG snapshots from a webcam to a folder on the web server.
So whilst the browser is open and taking snapshots i want another browser client from a different IP to be able to see the same stream.
Currently I do this.
index.php takes the snapshots from the webcam then upload the image to a folder on the server over and over and its overwriting the jpeg everytime.
The second browser from a different IP then constantly updates a css DIV with the image using an interval.
I'm adding a date stamp to the file to ensure it keeps downloading the latest image instead of keeping the cached image.
webcam.jpg?filetime+newint
See below.
The above very inefficient and also causes the div to flicker every time it downloads the image.
I'm not sure how I should approach this and my Java script skills is of the worst.
When uploading the image im using a simple PHP upload, is there a way I can have the below upload script append the image to become a M-Jpeg instead of overwriting it all the time ?
So whilst the browser is open and taking snapshots i want another browser client from a different IP to be able to see the same stream.
Currently I do this.
index.php takes the snapshots from the webcam then upload the image to a folder on the server over and over and its overwriting the jpeg everytime.
The second browser from a different IP then constantly updates a css DIV with the image using an interval.
I'm adding a date stamp to the file to ensure it keeps downloading the latest image instead of keeping the cached image.
webcam.jpg?filetime+newint
See below.
Code:
<div id="StreamWindow" ></div>
<script language="JavaScript">
var sec = 0;
setInterval(Load_stream, 500);
function Load_stream()
{
sec = sec + 1;
document.getElementById('StreamWindow').innerHTML = '<img src="uploads/webcam.jpg?<?php echo filemtime('uploads/webcam.jpg') ?>' + sec + ' "/>' ;
}
</script>
The above very inefficient and also causes the div to flicker every time it downloads the image.
I'm not sure how I should approach this and my Java script skills is of the worst.
When uploading the image im using a simple PHP upload, is there a way I can have the below upload script append the image to become a M-Jpeg instead of overwriting it all the time ?
PHP:
<?php
// be aware of file / directory permissions on your server
move_uploaded_file($_FILES['webcam']['tmp_name'], 'uploads/webcam.jpg');
?>
Last edited: