1

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?

georgeawg
  • 48,608
  • 13
  • 72
  • 95
  • Check if your web application server support the specific POST API endpoint which the code is calling. HTTP status code 405 indicates that the http method is not supported. Read up [here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/405) – Samuel Kok Nov 30 '18 at 09:02
  • When posting objects created by the [FormData API](https://developer.mozilla.org/en-US/docs/Web/API/FormData), it is important to set the Content-type header to `undefined`. – georgeawg Nov 30 '18 at 14:02

0 Answers0