DeathStar Posted June 1, 2007 Share Posted June 1, 2007 Hello. Can someone tell me how I can get a txt file, or its contents this way: Running a cron every 30 minutes, get file contents or download the txt file. Save it on sever. Thankyou. Link to comment https://forums.phpfreaks.com/topic/53916-downloading-from-another-servertxt-file/ Share on other sites More sharing options...
per1os Posted June 1, 2007 Share Posted June 1, 2007 create a php file that the cron runs either with a browser link lynx or someway similiar. <?php $contents = file_get_contents($filetoget); $date = date('Y-m-d-h-i-s', time()); $date = $date . rand(1,100000000); // randomize the number $fp = fopen($date, 'w+'); // writing create file if nto exists. fwrite($fp, $contents); fclose($fp); ?> Than just have the cron job run that file via lynx or however you wanna do it. Link to comment https://forums.phpfreaks.com/topic/53916-downloading-from-another-servertxt-file/#findComment-266572 Share on other sites More sharing options...
DeathStar Posted June 1, 2007 Author Share Posted June 1, 2007 Thankyou alot. <?php $filetoget = 'http://web.com/file.txt'; $contents = file_get_contents($filetoget); $dname = 'tribes.txt'; // randomize the number $fp = fopen($name, 'w+'); // writing create file if nto exists. fwrite($fp, $contents); fclose($fp); $size = filesize('tribes.txt'); echo $size.'bytes retrived.'; ?> Link to comment https://forums.phpfreaks.com/topic/53916-downloading-from-another-servertxt-file/#findComment-266576 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.