When slice is used for file cutting, FileReader is used to get the result error of each cutting element.

1. A large file cutting test is realized by using slice and fileReader. The idea is to segment the files [0] file obtained in the onchange of input type= "file" using files [0] .slice (start,end) according to the size of chunkSize, and instantiate a FileReader object each time in the process of segmentation, listen for onLoad events, and get the corresponding result, result error report after onLoad.
2.`
< html >
< head >

<title>This is a test about file</title>

< / head >
< body >

<input type="file" id="myfile" name="myfile" onchange="dealup()"/>
<button onclick="showresult()">Show result</button>

< / body >
< script >

const chunkSize = 10;
var myresult = new Array();
function dealup() {
    var file =document.getElementById("myfile").files[0];
    var chunks = Math.ceil(file.size/chunkSize);
    var filder = new Array(chunks);
    var start = 0,end = 0;
    console.log(""+file.size);
    for(let curindex = 0; curindex < chunks;curindexPP) {
            var tempcell = {
            data: "",
            n: 0
        };
        if(file.size-start <= chunkSize) {
            end = file.size;
        }else {
            end = start + chunkSize;
        }
        console.log(":"+start + " " + end);
        tempcell.n = curindex;
        filder[curindex] = new FileReader();
        filder[curindex].readAsText(file.slice(start,end));
        filder[curindex].onload = function() {
            console.log(curindex + "-sharp ")
            tempcell.data = filder[curindex].result;
             myresult.push(tempcell)
        }
        start = end;
        curindexPP;
    }
}
function showresult() {
    console.log(myresult);
}

< / script >
< / html > `

3. Result:

Feb.28,2021

should be the reason for curindexPP twice

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3adc6-2b794.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3adc6-2b794.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?