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

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -