react-drag-drop-files icon indicating copy to clipboard operation
react-drag-drop-files copied to clipboard

If the input is required and we use drag and drop to upload the file, then on form submit, it says field is required.

Open SciSaif opened this issue 2 years ago • 2 comments

If the input is required and we use drag and drop to upload the file, then on form submit, it says field is required even if the file is uploaded, so it doesn't let me submit. right now I am handling the required part manually.

SciSaif avatar Jun 09 '23 13:06 SciSaif

I have the same problem too, is there a way to avoid this problem?

I would avoid to add required as a state if possible.

The code is the same as in the example, i just added the field required:

import React, { useState } from "react";
import { FileUploader } from "react-drag-drop-files";

const fileTypes = ["JPG", "PNG", "GIF"];

function DragDrop() {
  const [file, setFile] = useState(null);
  const handleChange = (file) => {
    setFile(file);
  };
  return (
    <FileUploader handleChange={handleChange} name="file" types={fileTypes} required />
  );
}

export default DragDrop;

jpiazzal avatar Feb 09 '24 10:02 jpiazzal

Hi, same issue here, wondering if anybody has found a way to deal with this?

MariusMez avatar Apr 22 '24 16:04 MariusMez