Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

104
Views
How to get upload progress for multiple files? (React + React-dropzone + Axios + onUploadProgress)

I'm trying to create a multi-upload drag and drop with React and react-dropzone. Everything works great, except that I can't seem to get the progress information for the uploads even though I'm using onUploadProgress with Axios.

Here's the code I'm using:

const onDrop = useCallback((acceptedFiles) => {
  acceptedFiles.forEach((file) => {
    let response = axios.put(`/api/files-endpoint`, file, {
      onUploadProgress: (progressEvent) => {
        console.log(`progress ${progressEvent}`);
      },
    });
  });

  setFiles(acceptedFiles);
}, []);

Am I doing something wrong? In the browser I have tried with both firefox and chrome, even throtthling the connection to slow 3g to see if it will trigger the condition on those circunstances but still no luck. Any help is appreciated.

almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The upload example in the axios repo uses a FormData object, try adapting your code to use FormData too

const onDrop = useCallback((acceptedFiles) => {
  acceptedFiles.forEach((file) => {
    const data = new FormData();
    data.append('file', file);
    let response = axios.put(`/api/files-endpoint`, data, {
      onUploadProgress: (progressEvent) => {
        console.log(`progress ${progressEvent}`);
      },
    });
  });

  setFiles(acceptedFiles);
}, []);
almost 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!