You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
17 lines
513 B
JavaScript
17 lines
513 B
JavaScript
window.addEventListener("load", function () {
|
|
let input = document.querySelector('input[type="file"]');
|
|
input.addEventListener("change", function () {
|
|
console.log(this.files);
|
|
if (this.files && this.files[0]) {
|
|
let img = document.querySelector("img");
|
|
img.onload = () => {
|
|
img.classList.add("visible");
|
|
input.classList.add("hidden");
|
|
URL.revokeObjectURL(img.src); // no longer needed, free memory
|
|
};
|
|
|
|
img.src = URL.createObjectURL(this.files[0]); // set src to blob url
|
|
}
|
|
});
|
|
});
|