ファイルを読み取るjavascriptがありますが、ファイルを選択するようユーザーに尋ねる必要はありません。私は、ファイルを読み込んで、私は、ファイルを選択するようにユーザーに依頼する必要はありませんジャバスクリプトを持っているファイルは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