Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: mssql node js documentation 
Javascript :: tolocalestring format dd-mm-yyyy 
Javascript :: jquery chek radio 
Javascript :: function call ready resize and load 
Javascript :: javascript replace p tags with new line 
Javascript :: javascript is array empty 
Javascript :: change key name in array of objects javascript 
Javascript :: javascript insert element after 
Javascript :: plotly in react 
Javascript :: js object loop 
Javascript :: reactsj substring 
Javascript :: how to get file type in javascript 
Javascript :: moment get iso week number 
Javascript :: change text size according to screen react native 
Javascript :: find by array of ids mongoose 
Javascript :: js remove first element from array 
Javascript :: javascript change background color setinterval 
Javascript :: js is undefined or null 
Javascript :: how to delete a letter from a string in javascript 
Javascript :: express-async-errors 
Javascript :: javascript how to select radio button 
Javascript :: find all voice chanels in category 
Javascript :: string to number 
Javascript :: how to insert an item into an array at a specific index javascript 
Javascript :: mapgetters with parameter 
Javascript :: sequelize migration add column 
Javascript :: reset page js 
Javascript :: how to remove the top border from table react bootstrap 
Javascript :: namespace in javascript 
Javascript :: delete axios token 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =