开发者

Tornado handler thinks POST is missing argument when Firebug shows the argument being sent

开发者 https://www.devze.com 2023-01-04 04:25 出处:网络
I have a simple form using a POST method, consisting of a text box and a file. After hitting submit, I can see the post in Firebug as follows:

I have a simple form using a POST method, consisting of a text box and a file. After hitting submit, I can see the post in Firebug as follows:

Parts       multipart/form-data
posttext    Some text
image   BlahJFIFBlahExifBlahPhotoshopBlahBinaryStuff etc...

The Tornado handler that receives it looks like:

class NewPostHandler(BaseHandler, MessageMixin):
    @tornado.web.authenticated 
    def post(self):
        message = {
            'posttext':self.get_argument('posttext'), 
            'image':self.get_argument('image'),
            etc          

But Tornado's handler returns:

[W 100618 23:07:32 we开发者_运维知识库b:775] 404 POST /a/message/new (127.0.0.1): Missing argument image

I'm not quite sure what I'm doing wrong here. Am I correct in thinking 'argument' means a input element's 'name' attribute? How can I make the handler see the argument?

Thanks for your help, I've been struggling with this for an hour and must admit I'm stumped!


For file uploads you should use self.request.files instead of self.get_argument().

0

精彩评论

暂无评论...
验证码 换一张
取 消