0

Image sources

Any way to change the image source to a chosen file with the input type = file button?

13th Mar 2021, 3:59 PM
bgcnhgfjd
bgcnhgfjd - avatar
4 ответов
+ 1
If I missunderstand you want to show an <img> updating their src attribute after select it from an <input> of type=file?
13th Mar 2021, 4:03 PM
David Ordás
David Ordás - avatar
+ 1
Maxwell in the MDN is well explained this case and many others like drag and drop Tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file How to... https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications 1. Add a change listener to input with the code 2. In their code read the file as data url 3. set this content to your img.src attribute Remember mark as valid if answer response/solve you requirements
13th Mar 2021, 4:12 PM
David Ordás
David Ordás - avatar
13th Mar 2021, 4:04 PM
bgcnhgfjd
bgcnhgfjd - avatar
0
David Ordás 🇪🇸 thank you so much! :)
13th Mar 2021, 4:14 PM
bgcnhgfjd
bgcnhgfjd - avatar