Delete ex1 Image Thumbnails
This commit is contained in:
@@ -1,37 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html>
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<title>Complete JavaScript Course</title>
|
|
||||||
<style>
|
|
||||||
.thumb {
|
|
||||||
max-height: 100px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<input type="file" multiple accept="image/*" />
|
|
||||||
<div class="output"></div>
|
|
||||||
<script>
|
|
||||||
const message = document.getElementById("message");
|
|
||||||
const output = document.querySelector(".output");
|
|
||||||
const myInput = document.querySelector("input");
|
|
||||||
myInput.addEventListener("change", uploadAndReadFile);
|
|
||||||
function uploadAndReadFile(e) {
|
|
||||||
const files = e.target.files;
|
|
||||||
for (let i = 0; i < files.length; i++) {
|
|
||||||
const file = files[i];
|
|
||||||
const img = document.createElement("img");
|
|
||||||
img.classList.add("thumb");
|
|
||||||
img.file = file;
|
|
||||||
output.appendChild(img);
|
|
||||||
const reader = new FileReader();
|
|
||||||
reader.onload = (function (myImg) { return function (ele) { myImg.src = ele.target.result; }; })(img);
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user