Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Upload extends React.Component {
- constructor(props){
- super(props)
- this.state = {
- file: null
- }
- this.handleChange = this.handleChange.bind(this)
- }
- handleChange(event) {
- this.setState({
- file: URL.createObjectURL(event.target.files[0])
- })
- }
- render() {
- return (
- <div>
- <input type="file" onChange={this.handleChange} />
- <img src={this.state.file} />
- </div>
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement