sanchez77 Posted December 28, 2010 Share Posted December 28, 2010 So my hosting server does not allow fopen anymore, so I was wondering if anyone had an alternative to copying a file from a remote server via a URL to a local folder? Any alternatives is apprecited. Link to comment https://forums.phpfreaks.com/topic/222777-file-copy/ Share on other sites More sharing options...
Zurev Posted December 28, 2010 Share Posted December 28, 2010 http://www.php.net/manual/en/function.copy.php The copy function allows you to do that, however I'm curious who your webhost is and why they restricted fopen? Link to comment https://forums.phpfreaks.com/topic/222777-file-copy/#findComment-1151997 Share on other sites More sharing options...
kenrbnsn Posted December 28, 2010 Share Posted December 28, 2010 Switch to a hosting company that allows it? What are you trying to do? You might be able to use curl. Ken Link to comment https://forums.phpfreaks.com/topic/222777-file-copy/#findComment-1151998 Share on other sites More sharing options...
sanchez77 Posted December 28, 2010 Author Share Posted December 28, 2010 hey guys, feel asleep last night, my hosting company is yahoo. I am trying to open a text file on NOAA servers, read it, put data into a table and then display the information. It was working fine and then they stopped it. This is the code I was using , now I need a new solution. $wx = array_map('trim',file("http://www.ndbc.noaa.gov/data/realtime2/BRBN4.txt")); $newwx = array(); foreach($wx as $i => $line) { if ($i > 1 && $i < { $tmp = array_filter(explode(' ',$line)); $q = "insert into brbn4 (year,month,day,hour,min,wdir,wspd,gst,waveht,dpd,apd,mwd,pres,atmp,wtmp,dewp,vis,ptdy,tide) values ('" . implode("','",$tmp) . "')"; $rw = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error()); } } Link to comment https://forums.phpfreaks.com/topic/222777-file-copy/#findComment-1152095 Share on other sites More sharing options...
kenrbnsn Posted December 28, 2010 Share Posted December 28, 2010 If using file with a URL doesn't work, then using copy won't work either. Look into curl Ken Link to comment https://forums.phpfreaks.com/topic/222777-file-copy/#findComment-1152096 Share on other sites More sharing options...
sanchez77 Posted December 28, 2010 Author Share Posted December 28, 2010 uggg. ok thanks, i am going to try and use curl. Thanks for your help. Link to comment https://forums.phpfreaks.com/topic/222777-file-copy/#findComment-1152136 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.