I'm trying to upload an image using the code sample given in Codepen
I'm having the file contents in my state variable and getting it in the console from the below mentioned submit function
_handleSubmit(e) {
e.preventDefault();
console.log(this.state.file)
payLoad = {
image: this.state.file,
}
axios({
method: 'post',
url: this.state.url+'/task',
data: payLoad,
headers: {
'content-type': 'multipart/form-data'
}
})
}
My console result of this.state.file is
File(128544)
lastModified:1508143324556
lastModifiedDate:Mon Oct 16 2017 14:12:04 GMT+0530 (India Standard Time) {}
name:"sample.png"
size:128544
type:"image/png"
webkitRelativePath:""
__proto__:File
But the Network shows image variable as {} in API request headers and image is not uploading. Can anyone help? As i'm new to ReactJS I'm really trouble in some features and forced to ask many questions here.