from urllib2.urlopen
"the HTTP request will be a POST instead of a GET when the data parameter is provided."
So something like (i'll use an image example just because it was so darn obscure to figure out):
import urllib
import urllib2
import numpy as np
import cv2
image_to_send = np.zeros(512, np.uint8)
buffer_image = \
np.array(cv2.imencode('.png', image_to_send)[1]).tostring()
post_data = \
urllib.urlencode((('img_type','.png'),('img_data',buffer_image)))
req = \
urllib2.urlopen('http://www.yourdestination.com/imageupload/', data=post_data)
if you want authentication, you'll need to subclass urllib.FancyURLopener
, and override prompt_user_passwd