tomtomdotcom Posted May 26, 2007 Share Posted May 26, 2007 I'm fooling around with this script that copys a file from a remote url to my server this works fine <?php $file = 'http://www.somecoolsite.com/imgs/pic.jpg'; $newfile = 'Imgs/pic.jpg'; if (!copy($file, $newfile)) { echo "failed to copy $file...\n"; } ?> this file pic.jpg will be changed on the remote site every 24hrs so I need this script to first check if the time elapsed since last copied is greater than 24hrs then to copy it again/update it. How would i go about this? I'm a newbie so please be specific. Thanks Link to comment https://forums.phpfreaks.com/topic/53081-noobie-needs-help-w-filectime/ Share on other sites More sharing options...
tomtomdotcom Posted June 1, 2007 Author Share Posted June 1, 2007 well I managed to get this working, thought I'd share this: this will every 6 hours copy the new file from the remote website to my server directory <?php $sourcefile = 'http://www.remotesite.com/imgs/pic.jpg'; $localfile = 'Imgs/pic.jpg'; $Diff = (time() - filectime("$localfile")); if ($Diff > 21600) { (copy($sourcefile, $localfile)); } ?> then I have another php file that loads the pic on my website: <?php @include('http://www.mywebsite.com/abovefile.php'); //this will run the above php script every time the page is loaded $botd= "/Imgs/pic.jpg"; $link= "/Imgs/pic.jpg"; $caption = "Babe Of The Day"; $block = " <div style='text-align:left'><a href='$link' target='_blank'><img src='$botd' width='160' border='0'/></a></div>"; $ns -> tablerender($caption, $block); ?> Hope someone else can benefit from my hors of noobing around with this Big thanks to all who responded to my plea for help Link to comment https://forums.phpfreaks.com/topic/53081-noobie-needs-help-w-filectime/#findComment-266101 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.