我一直试图在我的视图为表单处理的发布请求中获取上载的文件。目前,这是我的代码:
filename = secure_filename(form_data.get('video_file'))
video_file = video_form.data.get('video_file')
video_path = '/media/tmp' + filename
video_file.save(video_path)
但是它不起作用,并在回溯AttributeError: 'str' object has no attribute 'save'
这是我的表格
class VidForm(FlaskForm):
"""New Genre Form."""
title = StringField('Title', validators=[validators.Length(min=3, max=75)])
description = StringField('Description', validators=[validators.Length(min=10, max=250)])
video_file = FileField('File')
submit = SubmitField('Upload')