MultipleFileField,您如何访问原始数据?

时间:2019-04-17 17:18:49

标签: python wtforms

关于此WTForms功能,SO上还有一些未解决的问题。似乎没有文档涵盖此字段与FileField之间的唯一性。有没有人有一个有效的示例,说明如何上传多个文件并使用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")

0 个答案:

没有答案