Aly*_*Aly 4 python upload flask
我有以下内容
<form action="classify_upload" method="post" id="upload-form">
<input type="file" name="imagefile" id="imagefile"/>
<input type="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)
在我的烧瓶webapp中,我有以下规则:
@webapp.route('/upload', methods=['POST'])
def upload():
try:
imagefile = flask.request.files['imagefile']
...
except Exception as err:
...
Run Code Online (Sandbox Code Playgroud)
但我得到了一个error 400: bad request,从我的谷歌搜索告诉我Flask无法在键下找到该文件,'imagefile'这是html中输入的名称.任何想法为什么它没有找到它?
结果我需要enctype在表单中包含,所以html应该是
<form action="classify_upload" method="post" id="upload-form" enctype="multipart/form-data">
<input type="file" name="imagefile" id="imagefile"/>
<input type="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2494 次 |
| 最近记录: |