You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
611 B
26 lines
611 B
class FileInput extends React.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.handleSubmit = this.handleSubmit.bind(this);
|
|
}
|
|
|
|
handleSubmit (event) {
|
|
event.preventDefault();
|
|
alert(`Selected file - ${this.fileInput.files[0].name}`);
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<form onSubmit={this.handleSubmit}>
|
|
<label>
|
|
Upload file:
|
|
<input type='file' ref={input => {this.fileInput = input}} />
|
|
</label>
|
|
<br/>
|
|
<button type='submit'>Submit</button>
|
|
</form>
|
|
);
|
|
}
|
|
}
|
|
|
|
ReactDOM.render(<FileInput />, document.getElementById('root'));
|
|
|