init
parent
dd57aea261
commit
533234ac68
Binary file not shown.
After Width: | Height: | Size: 227 KiB |
Binary file not shown.
After Width: | Height: | Size: 224 KiB |
@ -1,25 +1,25 @@
|
||||
let fileName = "";
|
||||
// let fileName = "";
|
||||
|
||||
window.addEventListener("load", function () {
|
||||
let input = document.querySelector('input[type="file"]');
|
||||
input.addEventListener("change", function () {
|
||||
if (this.files && this.files[0]) {
|
||||
fileName = this.files[0].name;
|
||||
let img = document.querySelector("img");
|
||||
img.onload = () => {
|
||||
img.classList.add("visible");
|
||||
input.classList.add("hidden");
|
||||
URL.revokeObjectURL(img.src); // no longer needed, free memory
|
||||
};
|
||||
// window.addEventListener("load", function () {
|
||||
// let input = document.querySelector('input[type="file"]');
|
||||
// input.addEventListener("change", function () {
|
||||
// if (this.files && this.files[0]) {
|
||||
// fileName = this.files[0].name;
|
||||
// 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
|
||||
}
|
||||
});
|
||||
});
|
||||
// img.src = URL.createObjectURL(this.files[0]); // set src to blob url
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
|
||||
const imageButton = document.getElementById("show-image");
|
||||
|
||||
imageButton.addEventListener("click", (e) => {
|
||||
let img = document.querySelector("img");
|
||||
img.classList.toggle("visible");
|
||||
img.classList.toggle("hidden");
|
||||
});
|
||||
|
@ -0,0 +1 @@
|
||||
const userID = Math.round(Math.random() * 10000000000);
|
Loading…
Reference in New Issue