Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Issue with multiple file validation #393

Closed
robscott95 opened this issue Feb 2, 2020 · 7 comments · Fixed by #556
Closed

Issue with multiple file validation #393

robscott95 opened this issue Feb 2, 2020 · 7 comments · Fixed by #556

Comments

@robscott95
Copy link

Hey, I'm having trouble with validating a wtforms.MultipleFileField field.

Creating a form field like so:
not_important = wtforms.MultipleFileField("Multiple file test",[FileRequired("File required"), FileAllowed(['csv'], ".csv file required")]) doesn't really work. After passing one or more files to the respective field, the validation returns "File required" error.
But the multi-dict of request.files shows that all files are read correctly.
Sample:
ImmutableMultiDict([('not_important', <FileStorage: 'Headline_all_test.csv' ('application/vnd.ms-excel')>)]

So basically the issue is - flask requests reads files passed, but the form.validate_on_submit() errors out telling me, that no file has been passed.

BTW - found this fresh SO thread pertaining to the same issue: https://stackoverflow.com/questions/59734277/filerequiredvalidator-doesnt-work-when-using-multiplefilefield-in-my-form

@HenriqueLin
Copy link

I think there is already an issue #337 about this problem and also a PR #338 by @greyli to solve this, but some how hasn't been merged yet. 😢

@snunzi
Copy link

snunzi commented Jan 11, 2022

I'm having the same issue, any work around?

@HenriqueLin
Copy link

I'm having the same issue, any work around?

I think you can create your own field and validation by copy the code from PR #338.

@greyli
Copy link
Member

greyli commented Jan 12, 2022

I will try to implement what David recommended late this month as an alternative to #338.

@iROCKBUNNY

This comment was marked as off-topic.

@khanfarhan10
Copy link

We really need this feature in flask wtforms, Any updates as to potentially when this could be updated please?

@greyli @HenriqueLin @robscott95

@azmeuk
Copy link
Member

azmeuk commented Oct 1, 2023

Fix released in v1.2.0

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 16, 2023
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

7 participants