86Stang Posted June 16, 2008 Share Posted June 16, 2008 Hello All, The company I work for is building a new building and they've installed a camera that snaps a photo every two minutes to capture the progress being made. The one pic is stored on a server outside of our web server and is over-written with each new snapshot so I'd like to be able to build a cron that grabs the pic every 15 minutes or so and save it to a folder on our web server so we'll have an actual stack of archived photos for posterity sake. Anyone have a good idea on how I could do this? Quote Link to comment https://forums.phpfreaks.com/topic/110502-solved-cron-job-to-grab-a-picture-from-an-external-site/ Share on other sites More sharing options...
hitman6003 Posted June 17, 2008 Share Posted June 17, 2008 just use the file_get_contents command... <?php $pic_location = "http://your.camera.page/pic.jpg"; file_put_contents('pic.' . date("Ymdhis") . '.jpg', file_get_contents($pic_location)); //or if you don't have php5: /* $open = fopen('pic.' . date("YmdHis") . '.jpg', 'wb'); fwrite($open, file_get_contents($pic_location)); fclose($open); */ Quote Link to comment https://forums.phpfreaks.com/topic/110502-solved-cron-job-to-grab-a-picture-from-an-external-site/#findComment-566898 Share on other sites More sharing options...
86Stang Posted June 17, 2008 Author Share Posted June 17, 2008 Rock on! Thanks! Hehe, I never thought I'd thank a hitman! Quote Link to comment https://forums.phpfreaks.com/topic/110502-solved-cron-job-to-grab-a-picture-from-an-external-site/#findComment-567320 Share on other sites More sharing options...
86Stang Posted June 17, 2008 Author Share Posted June 17, 2008 I think I spoke too soon. I don't have php5 and I'm getting this error: Warning: fopen(pic20080617081322.jpg) [function.fopen]: failed to open stream: Permission denied in /home/mysite/myfolder/pic_grab.php on line 5 Here's the code: <?php $pic_location = "http://my.camera.page/pic.jpg"; $open = fopen('pic.' . date("YmdHis") . '.jpg', 'wb'); fwrite($open, file_get_contents($pic_location)); fclose($open); ?> Quote Link to comment https://forums.phpfreaks.com/topic/110502-solved-cron-job-to-grab-a-picture-from-an-external-site/#findComment-567336 Share on other sites More sharing options...
86Stang Posted June 17, 2008 Author Share Posted June 17, 2008 Nevermind, I'm stupid. The folder needed write permissions. Der!!! Quote Link to comment https://forums.phpfreaks.com/topic/110502-solved-cron-job-to-grab-a-picture-from-an-external-site/#findComment-567371 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.