<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
请选择一个文件:<input type="file" id="input" multiple>
</body>
<script>
const inputElement = document.getElementById("input");
inputElement.addEventListener("change", handleFiles, false);
function handleFiles() {
const files = this.files;
for (let i = 0, numFiles = files.length; i < numFiles; i++) {
const file = files[i];
console.log(file.name);
console.log(file.size);
console.log(file.type);
}
}
</script>
</html>