Image sources | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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
rewfsgdf
rewfsgdf - avatar
4 Respostas
+ 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
rewfsgdf
rewfsgdf - avatar
0
David OrdĆ”s šŸ‡ŖšŸ‡ø thank you so much! :)
13th Mar 2021, 4:14 PM
rewfsgdf
rewfsgdf - avatar