0
예를 들어 파일 작성과 같은 파일에 ActiveX 기능을 사용하고 있습니다. 나는 그것이 파일의 라인에서 길이를 가져 오는 것이 가능한지 알아야한다. flow.AtEndOfStream이 완료되면 제어하는 데 사용하지만 이제는 파일의 행 길이를 가져와야합니다.이 작업을 수행 할 수 있습니까?javascript로 txt 파일의 길이를 얻는 방법
예를 들어 파일 작성과 같은 파일에 ActiveX 기능을 사용하고 있습니다. 나는 그것이 파일의 라인에서 길이를 가져 오는 것이 가능한지 알아야한다. flow.AtEndOfStream이 완료되면 제어하는 데 사용하지만 이제는 파일의 행 길이를 가져와야합니다.이 작업을 수행 할 수 있습니까?javascript로 txt 파일의 길이를 얻는 방법
HTML 파일 업로드 양식 : 파일 업로드 양식
<input type="file" id="fileinput" name="fileinput">
이벤트 리스너 :
function showLength(fileUploadEvent) {
var linesArray;
var reader = new FileReader();
// set up the event handler for when the file is loaded
reader.onload = function() {
console.log("Total file length: " + this.result.length);
linesArray = this.result.split('\n');
for (var i=0, l=linesArray.length; i<l; i++) {
console.log("Line #" + i + " Length: " + linesArray[i].length);
}
}
// fire off the loading of the file as a text file
reader.readAsText(fileUploadEvent.target.files[0]);
}
전체 plunkr 여기 예를 http://plnkr.co/edit/Kcf4LAlxN5Hqgjg0cEJb
확인 : 리스너
콜백 하지만 '변경'은 나에게 줄을 표시하지 않습니다 .. – pollonz
줄은 linesArray에 있습니다. 콘솔에 길이를 쓰고 있지만 내용은 linesArray에 있으며 원하는대로 할 수 있습니다. 총 길이는 this.result.length입니다. 총 행 수는 linesArray.length입니다. 너는 무엇을 더 찾고 있니? – jdforsythe