Problems with File Upload field
See original GitHub issueI’m having really hard times trying to make input[type=file]
play nicely with mobx-react-form
.
It doesn’t work out of the box and native behavior is broken.
When a file is chosen field.files
property got updated, but:
- Native input is not updated (still shows: “No file selected”)
- Validation of the field is not called, so the form is still rendered invalid
form.values()
does not contain files selected, so basically you have to implement your own method to collect all the values
Can someone provide a very simple and limited example of the form with one required input[type=file]
with form validation on file selection change and collecting the data for submit without picking data from the field itself?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Why Most File Uploads Fail (And What to Do About It)?
Here we list a few common reasons that lead to file upload failure, and some options for solving these problems.
Read more >Problem with file upload field - Jotform
Problem with file upload field ... Hi there,. Is there a reason the file loading widget at the end of this form is...
Read more >File Upload Troubleshooting | Submittable Help Center
If you are having difficulties uploading files to a form you're trying to complete, please try the following troubleshooting steps:.
Read more >NativeCloud File Upload Field Not Working
A small subset of NativeCloud users may experience problems with regard to using the Formstack Native File Upload field on their forms.
Read more >Problems getting File Upload field to pass a JPG file to a CPT ...
All other fields are passing successfully into to their CPT counterparts ok, but the JPG file uploaded to the Forminator Form is not...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
for anyone that sees this in the future, this is what I ended up doing:
Rendered component
Form initialization
Form submission
Explanation
https://stackoverflow.com/questions/1084925/input-type-file-show-only-button
<input>
tag usingdisplay: none
(it is still rendered, technically, just hidden with CSS - so it has the field’s event handling)shortid
libraryform.$('image').files
@Dakkers It will be too difficult to extract the working POC from the current project, as there are lots of custom code.