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.
11 lines
338 B
JavaScript
11 lines
338 B
JavaScript
document.querySelector('input[type="file"]').addEventListener("change", function () {
|
|
if (this.files && this.files[0]) {
|
|
var img = document.querySelector("img");
|
|
img.onload = () => {
|
|
URL.revokeObjectURL(img.src); // no longer needed, free memory
|
|
};
|
|
|
|
img.src = URL.createObjectURL(this.files[0]); // set src to blob url
|
|
}
|
|
});
|