Click to See Complete Forum and Search --> : Need a little assist with some php...


7Priest7
September 16th, 2010, 06:15 PM
I have a security camera that I want the JPGs courtesy of Fwink kept off site...

Although apparently I am getting rusty with php...

I tried

<? php
if(time() >= file_get_contents('time.txt')+10){
$a = 'camshots/' . date('y') . '/' . date('m') . '/' . date('d') . '/' . date('H.i.s') . '.jpg';
copy('camshots/webcam.jpg',$a);
file_put_contents('time.txt',time());
}
?>


That created a file in the main directory that looked sorta like "camshots/10/09/16/5.10.55.jpg"

So I tried adding

if(!file_exists('camshots/' . date('y') . '/' . date('m') . '/' . date('d') . '/'))
mkdir('camshots/' . date('y') . '/' . date('m') . '/' . date('d') . '/' );

before the copy code however that just made the script non responsive...

Any suggestions?
Better methods?
Leaner code to do it?

Thanks in advance

PeejAvery
September 17th, 2010, 10:17 AM
Create a global variable for the actual directory. Then you can constantly access one defined variable throughout the script.