0

This may sound unusual, but is there a way to change the value/source of an input type File Upload element to upload an image that is already in the DOM?

so I have:

<img src="myimage.jpg">

<input type="file">

I would like a trigger so that the file upload is uploading myimage.jpg which is already in the DOM

user9114945
  • 289
  • 3
  • 14

1 Answers1

1

No. You can't set the value of a file input (other than to blank it) at all.

You could set a hidden input to the image's URL (either its original URL or a data: scheme URL you generate with JS) and have your server-side code check for that as well as the file input value in the submitted form data.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335