Skip to content

Instantly share code, notes, and snippets.

@phsantiago
Created June 20, 2016 20:17
Show Gist options
  • Save phsantiago/bdabe38398e66467475dc74261274b8d to your computer and use it in GitHub Desktop.
Save phsantiago/bdabe38398e66467475dc74261274b8d to your computer and use it in GitHub Desktop.
private function ocDownloadImg($url){
$filename = end(explode('/', $url));
$saveIn = DIR_IMAGE . '/downloaded/' . $filename;
$ch = curl_init($url);
$fp = fopen($saveTo, 'wba');
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
fclose($fp);
return 'downloaded/' . $filename;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment