FAQ
Hi,


I want to use http post to upload data to a webserver but I want to pass multiple arguments within the post i.e.
I know that you can load one item (data)in there like this:
    data = {"data":open(filename,"rb")}
    response = opener.open(url, data, timeout=TIMEOUT)
but now I want multiple so I tried this:
         multipart = ({"data":data}, {"fname":fname}, {"f":f})
         response = opener.open(url, multipart, timeout=TIMEOUT)


but I get an error saying "'tuple' object has no attribute 'items'"... how do I do this correctly?


Thank you!
Ron

Search Discussions

  • Chris Angelico at Aug 16, 2013 at 12:45 am

    On Thu, Aug 15, 2013 at 7:12 PM, cerr wrote:
    multipart = ({"data":data}, {"fname":fname}, {"f":f})

    but I get an error saying "'tuple' object has no attribute 'items'"... how do I do this correctly?

    You're no longer providing a dictionary, but a tuple of dictionaries.
    What you want to do is use a single dictionary:


    multipart = {"data":data, "fname":fname, "f":f}


    That should achieve what you want.


    ChrisA

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedAug 15, '13 at 6:12p
activeAug 16, '13 at 12:45a
posts2
users2
websitepython.org

2 users in discussion

Cerr: 1 post Chris Angelico: 1 post

People

Translate

site design / logo © 2021 Grokbase