i am trying to do a file upload to a api but i want it to happen with out a submit button
how can i upload a file to a api with out submit button
class Profile extends React.Component {
constructor(props) {
super(props);
this.state = {
files: {
profile_img: null,
},
};
on change funtion
onChange(e) {
let files = this.state.files;
files[e.target.name] = e.target.files[0];
this.setState({
files: files,
});
}
<input type="file"name="profile_img" onChange={this.onChange}/>