I am allowing the user to load images into a page via drag&drop and other methods. When an image is dropped, I'm using URL.createObjectURL
to convert to an object URL to display the image. I am not revoking the url, as I do reuse it.
So, when it comes time to create a FormData
object so I can allow them to upload a form with one of those images in it, is there some way I can then reverse that Object URL back into a Blob
or File
so I can then append it to a FormData
object?
Modern solution:
let blob = await fetch(url).then(r => r.blob());
The url can be an object url or a normal url.