In lines 04 and 08, which code allows the user to select an image from their local computer, and to display the image in the browser?
is below:
<input type=”file” onchange=”previewFile()”>
<img src=”” height=”200” alt=”Image Preview…”/>
The JavaScript portion is:
01 functionpreviewFile(){
02 const preview = document.querySelector(‘img’);
3 const file = document.querySelector(‘input[type=file]’).files[0];
4 //line 4 code
5 reader.addEventListener(“load”, () => {
6 preview.src = reader.result;
7 },false);
08 //line 8 code
09 }
In lines 04 and 08, which code allows the user to select an image from their local computer, and to display the image in the browser?
A . 04 const reader = new File();08 if (file) URL.createObjectURL(file);
B . 04 const reader = new FileReader();08if (file) URL.createObjectURL(file);
C . 04 const reader = new File();08 if (file) reader.readAsDataURL(file);
D . 04 const reader = new FileReader();08 if (file) reader.readAsDataURL(file);
Answer: D
Latest JavaScript Developer I Dumps Valid Version with 144 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund