How to copy image from external resource

function get_page_content($url)
{
  $resource = curl_init();
 
  curl_setopt($resource, CURLOPT_URL, $url);
  curl_setopt($resource, CURLOPT_HEADER, false);
  curl_setopt($resource, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($resource, CURLOPT_CONNECTTIMEOUT, 30);
 
  $content = curl_exec($resource);
 
  curl_close($resource);
 
  return $content;
}
 
$content = get_page_content('http://www.google.co.uk/intl/en_com/images/srpr/logo1w.png');
 
$fp = fopen('logo.png', 'w');
fwrite($fp, $content);
fclose($fp);