파일을 읽는 자바 스크립트가 있지만 파일을 선택하도록 사용자에게 묻지 않습니다. 나는 파일이 내가 파일을 읽는 자바 스크립트를 window.onload
파일 판독기에 로컬 파일 경로 사용
function handleFiles(files) {
if (window.FileReader) {
getAsText(files[0]);
} else {
alert('FileReader are not supported in this browser.');
}
}
function getAsText(fileToRead) {
var reader = new FileReader();
reader.onload = loadHandler;
reader.readAsText(fileToRead);
}
function processData(event) {
var csv = event.target.result;
var allTextLines = csv.split(/\r\n|\n/);
var lines = [];
while (allTextLines.length) {
lines.push(allTextLines.shift().split(','));
}
console.log(lines);
}
브라우저가 보안상의 이유로 허용하지 않습니다 – Viney