Upload Image
const uploadInput = document.body.appendChild(
Object.assign(document.createElement('input'), {
type: 'file',
accept: 'image/png, image/jpeg'
})
);
const imageEl = document.body.appendChild(
Object.assign(document.createElement('img'), {
style: `
display:block;
width: 100%;
`
})
);
const reader = new FileReader();
reader.addEventListener('load', () => {
imageEl.src = reader.result;
});
uploadInput.addEventListener('change', e => {
const file = e.target.files[0];
if (file != null) {
reader.readAsDataURL(file);
}
});
Load an image into memory…