firelab-general/static/js/img_preview.js

10 lines
283 B
JavaScript
Raw Normal View History

2022-11-04 17:55:25 -07:00
let imgPreview = document.getElementById('img-preview');
let imgUpload = document.getElementById('img-upload');
imgUpload.onchange = event => {
const [file] = imgUpload.files;
if (file) {
console.log(file)
imgPreview.src = URL.createObjectURL(file);
}
};