Created
September 23, 2014 14:08
-
-
Save tribulant/502d44a2a84e6c0614cd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//if the file doesn't exist, we'll try to copy it. | |
if (!file_exists($imagepath)) { | |
//Get the file | |
if ($content = file_get_contents($m[1])) { | |
if (!empty($content)) { | |
//Store in the filesystem. | |
$fp = fopen($imagepath, "w"); | |
fwrite($fp, $content); | |
fclose($fp); | |
} | |
} else { | |
if (!function_exists('curl_init')){ | |
die('CURL is not installed!'); | |
} | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $m[1]); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
$output = curl_exec($ch); | |
curl_close($ch); | |
$content = $output; | |
$fp = fopen($imagepath, "w"); | |
fwrite($fp, $content); | |
fclose($fp); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment