javascript - What is the correct fetch body in React with FileReader -


i have react app gets data upload. want send data (mostly csv's) row row api. problem cannot correct value.

const uploadlocalfile = (file)  => (dispatch)  => {  const reader = new filereader()     reader.onload = evt => {         fetch("some/api/here",             {                 credentials: "same-origin",                 method: "post",                 body: //file, evt.target.result ?? <---              })         }     reader.readastext(file)     alert("done.") } 

file whole file, evt.target.result not allowed in react? evt.currenttarget forbidden fetch?

what mean "not allowed in react"? passing function handler file input should work:

handleselectfile = (event) => {   const file = event.currenttarget.files[0]   const reader = new filereader()   reader.onload = (event) => {     const content = event.target.result     // whatever want do `content`   }   reader.readastext(file) } 

Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -