On Mar 19, 7:20 am, Justin Ezequiel <justin.mailingli...@gmail.com> wrote: > On Mar 19, 8:50 am, Thomas Robitaille <thomas.robitai...@gmail.com> > wrote: > > > I am trying to upload a binary file (a tar.gz file to be exact) to a > > web server using POST, from within a python script. > > > What I would like is essentially the equivalent of > > > <form name='proceedings' method='post' action='www.whatever.com' > > enctype="multipart/form-data"> > > <input name="userfile" type="file"> > > </form> > > have you seenhttp://code.activestate.com/recipes/146306/
or you can use pycurl >>> import pycurl >>> c = pycurl.Curl() >>> c.setopt(pycurl.URL, "http://www.whatever.com") >>> c.setopt(pycurl.POST, 1) >>> filepath = "/path/of/file" >>> filename = "filename" >>> c.setopt(pycurl.HTTPPOST, [('userfile', (pycurl.FORM_FILE, file_path, >>> pycurl.FORM_FILENAME, filename))]) >>> c.perform() read pycurl doc for more details. http://pycurl.sourceforge.net/doc/pycurl.html -- http://mail.python.org/mailman/listinfo/python-list