Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

preview image before upload reactjs

state = {
  img: logo
}

handleChangeImage = e => {
  this.setState({[e.target.name]: URL.createObjectURL(e.target.files[0])})
}

<input type="file" id="img" name="img" accept="image/*" className="w-100" onChange={this.handleChangeImage}/>

<img src={this.state.img} alt="img"/>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #preview #image #upload #reactjs
ADD COMMENT
Topic
Name
6+9 =