Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Support for "file" type #24

Open
funmu opened this issue Nov 21, 2020 · 1 comment
Open

Support for "file" type #24

funmu opened this issue Nov 21, 2020 · 1 comment

Comments

@funmu
Copy link

funmu commented Nov 21, 2020

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?

@elmaraliyevdev
Copy link

I have a similar issue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants