【发布时间】:2015-03-17 15:01:55
【问题描述】:
您好,我有以下 html
<form action="classify_upload" method="post" id="upload-form">
<input type="file" name="imagefile" id="imagefile"/>
<input type="submit" />
</form>
在我的flask webapp 中,我有以下规则:
@webapp.route('/upload', methods=['POST'])
def upload():
try:
imagefile = flask.request.files('imagefile', '')
...
except Exception as err:
...
但这给了我以下异常
'ImmutableMultiDict' object is not callable
我不知道这意味着什么或为什么会发生。有什么想法吗?
【问题讨论】:
-
我认为你必须在表单标签上添加
enctype = 'multipart/form-data'才能像<form action="classify_upload" method="post" id="upload-form" enctype = 'multipart/form-data>没有该属性烧瓶会抛出 400 错误请求