Why do you need to store the file contents in an array? Can you not just call
doUploadFile()
for each file being uploaded? The reason I ask is because storing file content in an array is going to use up memory (RAM) on the client's machine. If a user uploads a 2GB document, you're asking the browser to store that 2GB document in memory which isn't a very good idea. For larger files you'd be better off streaming them to the back-end, which means using something called "chunking" which is where the browser takes parts of the large document and uploads piece-by-piece to avoid loading the whole thing into RAM.
Here's an article with a good example of how to chunk files[
^]
TL;DR - You shouldn't expect to be able to load entire documents into memory in JS, the browser might stop this to prevent using up too much memory.