Try this:
public function getFileUsingCurl($url)
{
//set all option
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
$file = curl_exec($ch);
$curlinfo = curl_getinfo($ch);
curl_close($ch);
$httpcode = $curlinfo['http_code'];
if($httpcode == "200"){
return $file;
}else{
return false;
}
}
Note:
Make sure you're not being redirected (code 301 or 302
)