Hi all,
Hope you can help with the following.. Im trying to retrieve a remote text file, and save it locally, downloading a new version every 2/3mins.
Im no expert with PHP so am trying to base it off a script I have where it downloads the file and saves it locally every 15mins (overwriting the previous one).
Ive tried mess around with the code, and I can get it to save the file locally with the correct filename, but I cant get it to download a new file everytime.
This is the portion of code I have trying to achieve the above..anyone know how to solve the problem?
$datamodtime=filemtime("data.txt");
$datemod2= date("Y-m-d-H-i-s", $datamodtime);
$now=time();
$dataremote=fopen($remotedatafilename,"rb");
$datalocal=fopen("data".$datemod2.".txt","w");
if (!$datalocal){
fclose ($dataremote);
} else {
while (strlen($data = fgets($dataremote, 1024)) != 0 ){
fwrite($datalocal,$data);
}
}
Ultimately, Im trying to get the file to download every 2/3mins, and I will then store certain info into a MySQL database (co-ordinates) to plot on a progress map.
Its a bit ambitious for a newbie like me to do, but Im hoping some help will set me on my way!
Cheers!