How to handle file picker in React

Issue #190

1
2
3
4
5
6
7
8
9
10
11
12
13
14
render() {
<Button color="inherit" onClick={this.onImagePress} >Image</Button>
<input ref="fileInput" type="file" id="myFile" multiple accept="image/*" style={{display: 'none'}} onChange={this.handleFiles}></input>
}

onImagePress = () => {
const fileInput = this.refs.fileInput
fileInput.click()
}

handleFiles = (e) => {
e.persist()
const file = e.target.files[0]
}

Comments