react-hooks-helper icon indicating copy to clipboard operation
react-hooks-helper copied to clipboard

Support for "file" type

Open funmu opened this issue 5 years ago • 1 comments

reacts-hooks-helper is a nice compact library that helps with forms and steps management.

When using the useForm() with input of type="file" , I found that the default binding does not preserve the values. Any insights on how to use the helper with file inputs.

For example

const GetFileData = (props) => {
  const { formData, setForm } = useForm( initialData);
 
 // ... some code skipped


  return (
     <form>
            <input type="file" id="inputfile" name="inputfile" onChange={setForm} />
     </form>
  ); 

};

For example when I upload a file, say "TestFile.txt"

the resulting formData does not have the file, but instead only has the file name as: formData = { inputfile: "c:\fakepath\TestFile.txt" }

is there a workaround?

funmu avatar Nov 21 '20 02:11 funmu

I have a similar issue

elmaraliyevdev avatar May 19 '21 07:05 elmaraliyevdev