-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuplod.js
29 lines (24 loc) · 823 Bytes
/
uplod.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
let fileInput=document.getElementById("file-input");
let imageContainer=document.getElementById("images");
let numofFiles=document.getElementById("num-of-files");
function preview()
{
imageContainer.innerHTML="";
numofFiles.textContent=`${fileInput.files.length}
Files Selected`;
for(i of fileInput.files)
{
let reader = new FileReader();
let figure =document.createElement("figure");
let figCap =document.createElement("figcaption");
figCap.innerText =i.name;
figure.appendChild(figCap);
reader.onload=()=>{
let img =document.createElement("img");
img.setAttribute("src",reader.result);
figure.insertBefore(img,figCap);
}
imageContainer.appendChild(figure);
reader.readAsDataURL(i)
}
}