效果

示例
DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>title>
head>
<body>
<input type="file" multiple="true" />
<script type="text/javascript">
window.onload = function(event) {
main();
}
function main() {
const inputFile = document.querySelector('input[type=file]');
inputFile.onchange = InputFile_onChange;
}
function InputFile_onChange(event) {
const files = event.target.files;
console.log(files);
}
script>
body>
html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
参考
HTML > Elements > input > input type=“file” - multiple