Tal vez no sea la mas ortodoxa o tenga algún bug de seguridad pero me funcionado de maravilla 
function portalimg_upload($input_img, $path = "uploads/posts/", $img_error = FALSE) {
	$input_img = preg_replace("#script:#i", "", $input_img);
	$ext = get_extension($input_img);	
	$input_img = file_get_contents($input_img);	
	if(preg_match("#^(gif|jpg|jpeg|jpe|bmp|png)$#i", $ext)) {
		$filename_1 = gmdate("Y_m")."_".TIME_NOW.".".$ext;
		$filename = $path.$filename_1;
		$temp = $path.md5(time().rand()); 
		$f = @fopen($temp, 'wb');
		if (!($f = @fopen($temp, 'wb'))) { 
			$img_error = TRUE;  
		} 
		fwrite($f, $input_img); 
		fclose($f); 
		if (!@rename($temp, $filename)) { 
			@unlink($filename); 
			@rename($temp, $filename); 
		}  
		@my_chmod($path.$filename, '0644');
	}
	else {
		$img_error == TRUE;
	}
	$portal_array = array(
		"error" => $img_error,
		"src"		=> $filename_1,
	);
	return $portal_array;
}
Si ven algún fallo de seguridad me gustaría que me lo hicieran saber