无法获取上传的文件并下载。烧瓶

时间:2020-05-02 14:52:35

标签: python flask

我一直试图在我的视图为表单处理的发布请求中获取上载的文件。目前,这是我的代码:

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')

0 个答案:

没有答案