1

There are a few unanswered questions here on SO about this WTForms feature. There seems to be no documentation covering the uniqueness between this and FileField. Does anyone have a working example for how to upload multiple files and access them all in python?

class RegistrationForm(FlaskForm):
username = StringField('Username', validators=[validators.Length(min=4, max=25), validators.DataRequired()])
password = PasswordField('Password', [validators.DataRequired()])
packets = MultipleFileField('Upload filesT')




@app.route('/', methods=['GET', 'POST'])
def index():

    form = forms.RegistrationForm()
    if request.method == 'POST':
        # Junk code for sake of exploration.
        if form.packets.data:
            print("files")
            print(form.packets.data)
            for file in form.packets.data:
                print(file)
            packet_filenames = secure_filename(form.packets.data)

        else:
            print("no files")
MrDysprosium
  • 489
  • 9
  • 20

0 Answers0