class.upload.php is a powerful and mature PHP class to manage uploaded files, and manipulate images in many ways. The script is available under a GPL license.
more info about the class
$add_post_url = your remote file $format = explode(".",$add_post_url); $path = '../uploads/posts/'.$randomizer.'.'.array_pop($format).''; copy(''.$add_post_url.'', ''.$path.''); $handle = new upload($path);