I’m trying to iterate over a list of files from a file input. However, it looks like the input’s value is an object instead of an array. How can I iterate over the array section of the object?
Actually found the solution here:
You need to use the values() function
You probably shouldn’t be looping over many files to be honest. I see this very often with people who come to consult to me. It becomes very inefficient and usually, handling any files, or multiple files is better done via a backend function. The loop solution is okay, but it brings a ton of issues with concerns about orphaned files when the process gets interrupted.
How else then would you upload multiple files without looping?
You could create an endpoint in your backend where you’d just send your files and it would handle it on the server. This way you don’t run into all the risks associated with doing this on the front-end. It’s a little more complex to set up, but the rewards are nice.
Thank you!
Hmm, wouldn’t it still need a loop though to iterate over the list of files to convert eache file to base 64 though before sending it to the backend? I don’t see how you can do this without using any loops
The problem is not the loop itself. It’s what the loop does.