I'm creating a plugin, so this topic is pertaining to code, not the in-admin media uploader.
I'm trying to upload an image to a post from an URL. I don't really know where to start. It looks like all the functions I've found deal with uploading files, not necessarily loading from an external URL.
I've saved images from an external source with PHP before by using fopen, however I'm needing to update the post and DB correctly so I would like to use a WP function, or for someone to let me know what I can do to create the function needed.