Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
// first, save medium image
$ch = curl_init($medium['source']);
$medium_local_path = UPLOAD_DIR.'/'.time().'_'.basename($medium['source']);
$parse = parse_url($medium_local_path);
$medium_local_path = $parse['path']; // clean up dirty query strings from file name
$fh = fopen($medium_local_path, "w");
curl_setopt($ch, CURLOPT_FILE, $fh);
curl_exec($ch);
curl_close($ch);
fclose($fh);
// then, the large image
$ch = curl_init($large['source']);
$large_local_path = UPLOAD_DIR.'/'.time().'_'.basename($large['source']);
$parse = parse_url($large_local_path);
$large_local_path = $parse['path']; // clean up dirty query strings from file name
$fh = fopen($large_local_path, "w");
curl_setopt($ch, CURLOPT_FILE, $fh);
curl_exec($ch);
curl_close($ch);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.