Created
April 20, 2020 11:24
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ImportFromFileBodyComponent = () => { | |
let fileReader; | |
const handleFileRead = (e) => { | |
const content = fileReader.result; | |
console.log(content) | |
// … do something with the 'content' … | |
}; | |
const handleFileChosen = (file) => { | |
fileReader = new FileReader(); | |
fileReader.onloadend = handleFileRead; | |
fileReader.readAsText(file); | |
}; | |
return <div className='upload-expense'> | |
<input | |
type='file' | |
id='file' | |
className='input-file' | |
accept='.csv' | |
onChange={e => handleFileChosen(e.target.files[0])} | |
/> | |
</div>; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment