New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to render multiple files uploaded using a single form field via MultipleFileField. #123
Comments
Hi @puludisumpia, Thanks for opening this issue & you're right that your example above is the current solution. I think the feature should be able to just return a list of file names stored via the Linked to Multiple file uploads #82 |
I have looked into accommodating multiple files & because this library is reliant on statically declared model attributes it would seem an anti pattern that would go against this aspect of the library design. A solution is then to create a model with a maximum amount of images as individual attributes:
Then in your view handler use Flask's
If the file list size is dynamic then get the size of the list and use the python range function to loop over your model's file attributes:
I'm going to close this issue as we have a work around & i have explained why we can't accommodate this feature, thanks. |
Thanks, maybe in the future you could allow to manage the uploaded files with flask-file-upload with Flask-Admin as well. Thank you for your reply. |
Limitations
I have a question: I want to build an application with Flask and I use flask-file-upload to save the files in the database but I am limited by the possibilities of flask-file-upload. So here is the model:
Here is the code that allows me to create the objects in the database and it works because I get to download the files and save them to the database.
So my question is this:
how to render these files in the templates?
Because the explanations provided, it is necessary to use:
This only works for one file. Me, I uploaded several files using the MultipleFileField of the Flask-WTF. Here is my the template of my form.
By reading the explanations, one of the solutions would be to create a field for each file to upload and then to render it one by one in the templates.
In the view:
In the template:
Is this the only solution? If not, can you tell me how to render them with uploaded files using a single MultipleFileField.
Thanks for your help.
The text was updated successfully, but these errors were encountered: