React прочитать несколько файлов с помощью FileReader
handleFileChosen = async (file) => {
return new Promise((resolve, reject) => {
let fileReader = new FileReader();
fileReader.onload = () => {
resolve(fileReader.result);
};
fileReader.onerror = reject;
fileReader.readAsText(file);
});
}
readAllFiles = async (AllFiles) => {
const results = await Promise.all(AllFiles.map(async (file) => {
const fileContents = await handleFileChosen(file);
return fileContents;
}));
console.log(results);
return results;
}
Lonely Curly Boi