📜  js 文件输入获取内容 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:58.393000             🧑  作者: Mango

代码示例1
//get file object
var file = document.getElementById('myFile').files[0];
if (file) {
  // create reader
  var reader = new FileReader();
  reader.readAsText(file);
  reader.onload = function(e) {
    // browser completed reading file - display it
    alert(e.target.result);                     
  };
}