WordPress Function Reference: media sideload image
Download an image from the specified URL and attach it to a post.
media_sideload_image($file, $post_id, $desc, $return);
Download an image from the specified URL and attach it to a post.
media_sideload_image($file, $post_id, $desc, $return);