Skip to content

Instantly share code, notes, and snippets.

@melvinmt
Created March 1, 2011 17:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melvinmt/849455 to your computer and use it in GitHub Desktop.
Save melvinmt/849455 to your computer and use it in GitHub Desktop.
<?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