How to get a remote file if file get contents() is not supported
From How2s
You might get an error looking something like this:
file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration
after you have enabled
error_reporting(E_ALL);
You can use an alternative to file_get_contents() which is CURL:
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
Or, if you use CakePHP, in your controller:
App::import('Core', 'HttpSocket');
$socket = new HttpSocket();
$response = $socket->request(array('uri' => $url));

