iH
Size: a a a
iH
S
const fileElement = document.querySelector('#file')
const createElement = (tag, attributes) => {
const element = document.createElement(tag)
for (const attributeIndex in attributes && Object.keys(attributes)) {
element.setAttribute(
Object.keys(attributes)[attributeIndex], // Property
attributes[Object.keys(attributes)[attributeIndex]] // Value
)
}
document.body.appendChild(element)
}
fileElement.addEventListener('change', event => {
for (const file of event.target.files) {
const reader = new FileReader()
reader.readAsDataURL(file)
reader.onload = () => createElement('img', {
src: reader.result,
width: '200px',
height: '150px'
})
}
})
B
F
N
iH
B
N
B
iH
N
iH
B
N
B
N