forked from BosNaufal/react-file-base64
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
58 lines (42 loc) · 1.18 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import React from 'react';
import ReactDOM from 'react-dom';
import FileBase64 from './react-file-base64.js';
class App extends React.Component {
constructor() {
super()
this.state = {
files: []
}
}
getFiles(files){
this.setState({ files: files })
}
render() {
return (
<div>
<h1 className="text-center">React File to Base64 Converter</h1>
<div className="text-center mt-25">
<p className="text-center"> *) Try To Upload Some Image~</p>
<FileBase64
multiple={ true }
onDone={ this.getFiles.bind(this) } />
</div>
<div className="text-center">
{ this.state.files.map((file,i) => {
return <img key={i} src={file.base64} />
}) }
<img src="" />
</div>
{ this.state.files.length != 0 ?
<div>
<h3 className="text-center mt-25">Callback Object</h3>
<div className="pre-container">
<pre>{ JSON.stringify(this.state.files, null, 2) }</pre>
</div>
</div>
: null }
</div>
)
}
}
ReactDOM.render(<App />, document.getElementById("app"))