How can I send a file over HTTP?

I tried with request parameter and it works fine.

[code1]
def handle_upload(files, id_user):
    url = URL_IMG_HANDLER_APP
    values = {''param1', 'value1'}
    req = urllib2.Request(url, data)
    urllib2.urlopen(req)

But if I try with binary files, the file size is always 0 on the other side:

def handle_upload(files, id_user):
    url = URL_IMG_HANDLER_APP
    values = {'file':files['file']} # 'files' from an upload and debugging
it looks fine
    data = urllib.urlencode(values)
    req = urllib2.Request(url, data)
    urllib2.urlopen(req)

Any thoughts?

Thanks in advance,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to