Answers for "react read multiple files with filereader"

0

react read multiple files with 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;
}
Posted by: Guest on August-28-2021

Code answers related to "react read multiple files with filereader"

Code answers related to "Javascript"

Browse Popular Code Answers by Language