Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration
What to do if you’ve got this:
Warning: fopen() [function.fopen]: URL file-access is disabled in the server configuration
Warning: fopen(http://somelocation.com/somefile.xml) [function.fopen]: failed to open stream: no suitable wrapper could be found in /home/someuser/somephpfile.php on line [someline :-)]
???
It happens if - for security reasons fopen is restricted to open remote files. If it is on a hosting server and you cannot change configuration you may try curl. Example below:
instead of:
$file = "http://somelocation.com/somefile.xml";
$fp = fopen($file, "r");
try the solution with curl*:
$file = "http://somelocation.com/somefile.xml";
$ch = curl_init($file);
$fp = @fopen("temp.xml", "w");
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
$file = "temp.xml";
$fp = fopen($file, "r");
That’s all
* - ensure that you have write access - so curl can write to temp.xml