input file类型文件上传获取文件内容前端做法

<input type="file" id="updateInput">
<script>
	let fileInput = document.getElementById("updateInput");
	fileInput.onchange = function(){
		let resultFile = document.getElementById("updateInput").files[0];
		let reader = new FileReader();
		reader.readAsText(resultFile,'UTF-8');
		reader.onload = function(e){
			let data = this.result;
			console.log(data);
		}
	}
script>

你可能感兴趣的:(js,html,javascript,html5)