Here is my onDrop function -
onHandleDrop = (files) => {
console.log(files);
if (files[0].size > fileMax) {
alert("File Size too big")
}
else {
const currentFile = files[0];
let formData = new FormData();
formData.append('file', currentFile);
axios.post(api_url + '/file/resume/upload',
formData, {
headers: {
'Content-Type': 'multipart/form-data'
}
}).then(resp => {
console.log("resp from submission " + JSON.stringify(resp))
if (resp.data.responseCode == "1000" && resp.status == "200") {
this.setState({ resume: resp.data.metadata, resumeMsg: true })
}
})
}
}
Here is my Dropzone component -
<Dropzone className="ignore" onDrop={files => this.onHandleDrop(files)} multiple={false} accept=".pdf,.doc">
<div style={{ borderStyle: "dotted", borderWidth: "100%%", textAlign: "center" }}>
{this.state.resume.length > 0 ? this.state.resume : "Drag & Drop your file here!"}
</div>
</Dropzone>
The thing is its not working with safari browser in mac. Its throwing 405.
Could someone please tell me where I am going wrong and what's the alternate of using new formData()
so that it supports all the browser. How can I send file to my java server?