p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Consolas; color: #2b9edb }
p.p2 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Consolas; color: #d76019 }
p.p3 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Consolas; color: #2eafa9 }
p.p4 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Consolas; color: #596972 }
p.p5 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Consolas; color: #3c7400 }
p.p6 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Consolas; color: #d8a100 }
p.p7 { margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Consolas; color: #060606 }
span.s1 { color: #596972 }
span.s2 { color: #2b9edb }
span.s3 { color: #2eafa9 }
span.s4 { color: #d76019 }
span.s5 { color: #ad5cff }
span.s6 { color: #97a700 }
span.s7 { color: #ff7900 }
span.s8 { color: #060606 }
span.s9 { color: #3c7400 }
span.s10 { color: #000000 }
span.s11 { color: #6b82d9 }
span.s12 { color: #d8a100 }
span.s13 { color: #b58a00 }
span.Apple-tab-span { white-space: pre }
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no, minimal-ui">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<title>多个文件上传</title>
</head>
<body>
<div style="height: 100px; width: 100px; border: 1px solid red; position: relative;">
点击上传
<input onchange="uploadFile()" id="upload" multiple="multiple" type="file" accept="image/*;capture=camera" style="height: 100px;width: 100px;opacity: 0;position: absolute;top: 0;left: 0;" />
</div>
<script>
function uploadFile() {
var input = document.getElementById(‘upload‘);
var files = Array.prototype.slice.call(input.files);
files.forEach(function(file, i) {
var reader = new FileReader();
reader.onloadend = function(e) {
var baseFileStr = this.result.substring((13 + file.type.length),this.result.length);
console.info("输出文件数据");
console.info(baseFileStr);
}
reader.readAsDataURL(file);
});
}
</script>
</body>
</html>
>>>输出文件数据
>>>iVBORw0KGgoAAAANSUhEUgAAABIAAAAOCAYAAAAi2...
原文地址:https://www.cnblogs.com/Alice-Xu/p/8559216.html