What about this?
Function
PHP Code:
<?php
/**
* Uses cURl to save a remote file locally.
*
* @param String $sRemoteFile
* @param String $sSaveTo
* @return Boolean
*/
function saveRemoteData( $sRemoteFile , $sSaveTo )
{
$rcUrlHandle = curl_init( $sRemoteFile );
curl_setopt( $rcUrlHandle , CURLOPT_RETURNTRANSFER , true );
$sData = curl_exec( $rcUrlHandle );
return (file_put_contents( $sSaveTo , $sData )) ? true : false ;
}
?>
Usage
PHP Code:
<?php
if( saveRemoteData( 'http://www.google.co.uk' , 'googlePage.html') )
{
echo 'Yay! We obtained the target file.';
}
else
{
echo 'Whoops, we could not obtain the data!';
}
?>
Bookmarks