React Component for Converting Files to base64. It's based on Dev Mozilla Website
You can import react-file-base64.js to your react component file like this and process it with your preprocessor.
You can install it via NPM
npm install react-file-base64
import React from 'react';
import ReactDOM from 'react-dom';
import FileBase64 from 'react-file-base64';
class App extends React.Component {
constructor() {
super()
this.state = {
files: []
}
}
// Callback~
getFiles(files){
this.setState({ files: files })
}
render() {
return (
<FileBase64
multiple={ true }
onDone={ this.getFiles.bind(this) } />
)
}
}
ReactDOM.render(<App />, document.getElementById("app"))
Does your component support multiple files?
Callback function when all files have been processed
Just Contact Me At:
- Email: bosnaufalemail@gmail.com
- Skype Id: bosnaufal254
- twitter: @BosNaufal
MIT Copyright (c) 2016 - forever Naufal Rabbani