helloflask / helloflask/bootstrap-flask
MultiFileField handling unclear
- Dominant language
- SCSS
- Stars
- 1.2k
- Forks
- 193
- Avg merge
- 4m
- Merged PRs (30d)
- 3
Description
I am trying to get http://fb4demo.bitplan.com/upload to work with the following code:
```python
class UploadForm(FlaskForm):
'''
upload form example
'''
file = MultipleFileField('File(s) to Upload')
submit = SubmitField()
```
```html
{% extends 'base.html' %}
{% from 'bootstrap/form.html' import render_form, render_field, render_form_row %}
{% block content %}
Dropzone.options.myDropzone.headers = {"X-CSRF-Token": "{{ csrf_token() }}"}
Upload Form
{{ render_form(upload_form) }}
{{ dropzone.create(action=url_for('test_upload')) }}
{{ dropzone.config() }}
{% endblock %}
```
```python
def upload(self):
'''
handle the uploading
'''
form= UploadForm()
filenames=""
delim=""
if form.validate_on_submit():
for file in form.file.data:
file_filename = secure_filename(file.filename)
filePath=f'/tmp/{file_filename}'
with open(filePath, 'wb') as f:
f.write(file.read())
size=os.path.getsize(filePath)
filenames=f"{filenames}{delim}{file_filename}({size})"
delim="
"
flash(Markup(filenames))
return render_template('upload.html',upload_form=form)
```
drag and drop works except #147 but when clicking submit the filenames are no available.

Instead the Filestorage objects are of type
```
str: application/octet-stream
```
Please advise how this should be done properly.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.