Created
April 20, 2020 11:24
-
-
Save ilonacodes/5159f439c801004ff6505179756fac9f to your computer and use it in GitHub Desktop.
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