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

147
Views
react-dropzone accepts all uploaded file types instead of specified file type(s) in "accept" parameter

My react-dropzone 'accept': { .. } parameter seems to be totally ignored when I am uploading files.

My useDropzone({}):

    const {getRootProps, getInputProps, isDragActive} = useDropzone({
        onDrop,
        noClick: true,
        'accept': {
            'video/mp4': ['.mp4', '.MP4'],
        },
    })

My onDrop Callback:

    const onDrop = useCallback((acceptedFiles, rejectedFiles) => {

        let test =  acceptedFiles.length || rejectedFiles.length
            ? `Accepted ${acceptedFiles.length}, rejected ${rejectedFiles.length} files`
            : "Try dropping some files.";

        console.log(test);

        if (acceptedFiles.length > 0) {
            setSelectedFiles(acceptedFiles);
        }

        acceptedFiles.forEach((file, index, array) => {

            const reader = new FileReader()

            reader.onabort = (event) => {
                console.log('file reading was aborted')
            }

            reader.onerror = (event) => {
                console.log('file reading has failed')
            }

            reader.onload = (event) => {

                // Do whatever you want with the file contents
                const binaryStr = reader.result
                console.log(binaryStr)

            }

            reader.readAsArrayBuffer(file)

        })


    }, [])

The code:

        let test =  acceptedFiles.length || rejectedFiles.length
            ? `Accepted ${acceptedFiles.length}, rejected ${rejectedFiles.length} files`
            : "Try dropping some files.";

always returns: Accepted 1, rejected 0 files

no matter what, rejected will always be 0 even when I uploaded pdf, jpg, txt etc

Here is the codesandbox Link: https://codesandbox.io/s/kind-frost-zmyhd8?file=/pages/index.js

Anyone knows what is wrong with my code?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

According to documentation you need to provide accept prop like below (without quotes) :

useDropzone({
  accept: {
    'video/mp4': ['.mp4', '.MP4'],
  }
})

Here is working solution.

about 4 years ago · Juan Pablo Isaza 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!