How can I write my own POST request in React Dropzone Uploader?

615 Views Asked by At

I am using React Dropzone Uploader in my react application, the getUploadParams method directly uploads the file to the server, which I want to be invoked after clicking a specific submit button. Is there any way to achieve this or to write my own POST request using axios?

2

There are 2 best solutions below

3
Priyanka Panjabi On

You can add onSubmit={handleSubmit} in Dropzone and make your post request in handleSubmit function.

const handleSubmit =(files, allFiles)=>{
console.log(files.map(f => f.meta));
    // post call 
}
 <Dropzone
        //other attributes
        onSubmit={handleSubmit}
      />
0
Leo Orotoma Ojigbo On

After reading the RDU api docs, you might need to manipulate uploads from getUploadParams. See the docs for getUploadParams here.