Insert Attachment from URL

The example for wp insert attachment() in the codex:

is extremely weak. how do i go about getting the $filename (which needs to be a path apparently) from a URL in the uploads folder?

OR, how do i get an attachment ID from media_image_sideload()?

basically i want to insert an attachment from a URL (that is in my uploads directory). these 2 functions each seem like half of the solution.