"react upload file axios" Code Answer's
You're definitely familiar with the best coding language Javascript that developers use to develop their projects and they get all their queries like "react upload file axios" answered properly. Developers are finding an appropriate answer about react upload file axios related to the Javascript coding language. By visiting this online portal developers get answers concerning Javascript codes question like react upload file axios. Enter your desired code related query in the search bar and get every piece of information about Javascript code related question on react upload file axios.
react upload file axios
import React from 'react'
import axios from 'axios';
class FileUpload extends React.Component{
constructor(){
super();
this.state = {
selectedFile:'',
}
this.handleInputChange = this.handleInputChange.bind(this);
}
handleInputChange(event) {
this.setState({
selectedFile: event.target.files[0],
})
}
submit(){
const data = new FormData()
data.append('file', this.state.selectedFile)
console.warn(this.state.selectedFile);
let url = "http://localhost:8000/upload.php";
axios.post(url, data, { // receive two parameter endpoint url ,form data
})
.then(res => { // then print response status
console.warn(res);
})
}
render(){
return(
<div>
<div className="row">
<div className="col-md-6 offset-md-3">
<br /><br />
<h3 className="text-white">React File Upload - Nicesnippets.com</h3>
<br />
<div className="form-row">
<div className="form-group col-md-6">
<label className="text-white">Select File :</label>
<input type="file" className="form-control" name="upload_file" onChange={this.handleInputChange} />
</div>
</div>
<div className="form-row">
<div className="col-md-6">
<button type="submit" className="btn btn-dark" onClick={()=>this.submit()}>Save</button>
</div>
</div>
</div>
</div>
</div>
)
}
}
export default FileUpload;
All those coders who are working on the Javascript based application and are stuck on react upload file axios can get a collection of related answers to their query. Programmers need to enter their query on react upload file axios related to Javascript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about react upload file axios for the programmers working on Javascript code while coding their module. Coders are also allowed to rectify already present answers of react upload file axios while working on the Javascript language code. Developers can add up suggestions if they deem fit any other answer relating to "react upload file axios". Visit this developer's friendly online web community, CodeProZone, and get your queries like react upload file axios resolved professionally and stay updated to the latest Javascript updates.