An image that has been replaced re-appears again if I click the upload window again

So I have this issue that I can’t seem to find a solution for. I have an ‘upload image’ area that’s part of my form. You’re allowed to either upload an image that has been downloaded on your computer or copy and paste an image address in the url, which should render the image in the image window. Everything works fine, except if:

  1. I upload a downloaded image from my computer downloaded-image

  2. I decide to instead copy an image url from the internet and use that instead image-from-internet

  3. The image from the internet appears and overwrites the old image

  4. I click on the image window again

  5. The old image reappears and overwrites my new image old-image

I’ve tried resetting the form control of the image window when the user clicks on it, but that ends up clearing the entire image window, discarding the image. How do I prevent the old image from overwriting my new image?