Considerations for html5 filereader Reading streams: html5filereader
New FileReader is required to intercept the read files, and the same reader cannot be called globally.
Error code !!!
Function readAsBinaryString (file, callback) {readrSpt (); var part = 0, fileName = file. name, step = 1024*10, start = 0, a = 0, B = 0, total = file. size, loaded = 0, reader = new FileRead (), fileType = file. type; // This write is incorrect, and the reader stream is not synchronized. // $ ("# fileLink "). attr ("href", URL. createObjectURL (blob); // read the file in the form of arraybuffer (function (start) {var blob = file. slice (start, start + step + 1), self = arguments. callee; // console. log (blob) reader. readAsArrayBuffer (blob); reader. onprogress = function (e) {loaded + = e. loaded; var per = loaded/total; if (loaded = total) {per = 100; callback (this. result, part, fileName, fileType, true);} else {per * = 100; callback (this. result, part); part ++;} reader. onload = function (e) {console. log (loaded) if (loaded <total) {self (loaded); // callback (this. result) ;}else {loaded = total ;}} (start );}
Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Correct code
Function readAsBinaryString (file, callback) {readrSpt (); var part = 0, fileName = file. name, step = 1024*10, start = 0, a = 0, B = 0, total = file. size, loaded = 0, fileType = file. type; // $ ("# fileLink "). attr ("href", URL. createObjectURL (blob); // read the file in the form of arraybuffer (function (start) {var blob = file. slice (start, start + step + 1), reader = new FileReader (), self = arguments. callee; // console. log (blob) reader. readAsArrayBuffer (blob); reader. onprogress = function (e) {loaded + = e. loaded; var per = loaded/total; if (loaded = total) {per = 100; callback (this. result, part, fileName, fileType, true);} else {per * = 100; callback (this. result, part); part ++;} reader. onload = function (e) {console. log (loaded) if (loaded <total) {self (loaded); // callback (this. result) ;}else {loaded = total ;}} (start );}
How does html5 FileaReader read files in segments?
How does a browser crash? Or page timeout?
Is the backend PHP? If yes, check whether the php. ini configuration allows uploading large files.
Upload_max_filesize maximum file size that can be uploaded. Unit: MB
Content occupied by memory_limit PHP script execution, in MB
Max_execution_time maximum PHP script execution time, in seconds
Post_max_size the maximum size of POST data. Unit: MB
Max_input_time maximum timeout time for reading uploaded data. Unit: seconds
In HTML5, garbled characters appear when reading a txt file containing Chinese characters using readAsText () under FileReader
Encoding problem, what is your Txt file encoding format, you can save it as a memory Gu UFT-8 try