【发布时间】:2013-09-14 12:53:03
【问题描述】:
我以这个链接为例上传图片:
https://gist.github.com/jdstanhope/5079277
我的 HTML 代码:
<form action="/upload_image" method="post" id="form1" runat="server">
<div class="fileButtons">
<input type='file' id="imgInp" name="imgInput" accept="image/*"/><br><br>
<input type='button' id='remove' value='Remove' />
</div></form>
main.py:
class SetImage(webapp2.RequestHandler):
def post(self):
logging.debug("test")
id = str(self.request.get('id'))
image = self.request.get('imgInput')
app = webapp2.WSGIApplication([('/upload_image', SetImage),
('/', MainPage)], debug=True)
但是当我添加图像时,什么都没有做,并且日志控制台不打印:
logging.debug("test")
【问题讨论】:
-
将 enctype='multipart/form-data' 添加到您的表单中。此外,除了为 id 和 image 分配值之外,post 似乎没有做任何事情。使用 logging.info 或简单打印
标签: python html google-app-engine webapp2