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. Quote 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. Quote 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.'; ?> Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.