Created
January 25, 2012 19:08
-
-
Save thiagosf/1677958 to your computer and use it in GitHub Desktop.
Download de imagem externa
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function _downloadImage ($url, $fullpath = 'local/path/') | |
{ | |
$pathinfo = pathinfo($url); | |
$fullpath = $fullpath . $pathinfo['basename']; | |
$out = $fullpath; | |
$ch = curl_init($url); | |
$fp = fopen($fullpath, 'wb'); | |
curl_setopt($ch, CURLOPT_FILE, $fp); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 60); | |
curl_exec($ch); | |
curl_close($ch); | |
fclose($fp); | |
return $out; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment