You need to specify a multiple attribute for the input tag. This can be done in your templates:
form.pictures(multiple="")
which will lead to the creation of the generated html, allowing you to select multiple files:
<input id="pictures" multiple name="pictures" type="file">
How to manipulate multiple files with request.files:
images = request.files.getlist("pictures")
if images:
for img in images:
# Create Images
file_name = str(uuid.uuid4()) + secure_filename(img.filename)
image_file = os.path.join(app.config['UPLOAD_FOLDER'], file_name)
img.save(image_file)
# Save record
image = models.Image(record_id=record.record_id,
file_name=file_name.encode('utf-8'))
db.session.add(image)
db.session.commit()
source
share