Reading multiple files with Javascript FileReader API one at a time

I came up with a solution myself which works. function readmultifiles(files) { var reader = new FileReader(); function readFile(index) { if( index >= files.length ) return; var file = files[index]; reader.onload = function(e) { // get file content var bin = e.target.result; // do sth with bin readFile(index+1) } reader.readAsBinaryString(file); } readFile(0); }

Large file upload with WebSocket

Use web workers for large files processing instead doing it in main thread and upload chunks of file data using file.slice(). This article helps you to handle large files in workers. change XHR send to Websocket in main thread. //Messages from worker function onmessage(blobOrFile) { ws.send(blobOrFile); } //construct file on server side based on blob … Read more

Failed to construct ‘File’: Iterator getter is not callable in chrome 60 when use JSON.stringify()

In your case File constructor signature is incorrect, the first argument must be: An Array of ArrayBuffer, ArrayBufferView, Blob, or DOMString objects — or a mix of any such objects. This is the file content encoded as UTF-8. https://developer.mozilla.org/en-US/docs/Web/API/File/File#Parameters new File([blob], “filename.json”, {type: “text/json;charset=utf-8”});

Getting byte array through input type = file

[Edit] As noted in comments above, while still on some UA implementations, readAsBinaryString method didn’t made its way to the specs and should not be used in production. Instead, use readAsArrayBuffer and loop through it’s buffer to get back the binary string : document.querySelector(‘input’).addEventListener(‘change’, function() { var reader = new FileReader(); reader.onload = function() { … Read more

How to set File objects and length property at FileList object where the files are also reflected at FormData object?

Edit: As proven by OP, in one of their gist, there is actually a way to do it… The DataTransfer constructor (currently only supported by Blink, and FF >= 62), should create a mutable FileList (chrome currently always return a new FileList, but it doesn’t really matter for us), accessible through the DataTransferItemList. If I’m … Read more

tech