Jump to content

Unable to download file with file_get_contents()


acecombat

Recommended Posts

I'm trying to run a script that I added to a cron every hour to automate downloading to a local file of external resources but get this error:

Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: No such host is known. in Q:\Webserver\htdocs\testscript.php on line 2

Warning: file_get_contents(http://www.abc.net.au/news/indexes/justin/rss.xml) [function.file-get-contents]: failed to open stream: Unknown error in Q:\Webserver\htdocs\testscript.php on line 2

It doesn't matter what I enter as the file path the error remains the same. I just tried the RSS XML file because I know it's plain text and I can access it fine. I don't think it has anything to do with accessing it via a transparent proxy as the error doesn't mention anything of the sort (I might be wrong however)

In case it makes any difference I'm running Abyss Web Server 2.5, PHP 5.1.4 on Windows XP Pro.

This is the code I was using:

<?php

$remoteFileContents=file_get_contents("http://www.abc.net.au/news/indexes/justin/rss.xml");

$localFilePath="l:";

$localFileName="rss.xml";

$newFileHandle = fopen($localFilePath."/".$localFileName, "w");

fwrite($newFileHandle, $remoteFileContents);

fclose($newFileHandle);

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.