showing results for - "get image url in react input file or preview form image"
Manuela
08 Oct 2019
1getInitialState: function(){
2  return{file: []}
3}
4
5_onChange: (event)=>{
6    this.setState({
7        imgs: event.target.files
8    })
9},
10
11render: function(){
12 return(
13  <div>
14    <form>
15      <input 
16        ref="file" 
17        type="file" 
18        name="user[image]" 
19        multiple="true"
20        onChange={this._onChange}/>
21    </form>
22
23    {/* Display all selected images. */}        
24    {this.state.imgs && [...this.state.imgs].map((file)=>(
25       <img src={URL.createObjectURL(file)} />
26    ))}
27
28  </div>
29 )
30}
31