question about posting data using MultipartPostHandler

C

cerr

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":eek:pen(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
 
C

Chris Angelico

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
44,998
Latest member
MarissaEub

Latest Threads

Top