Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Extend urllib2 to support HTTP POST file upload
branch: master

This branch is even with seisen:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
tests
.gitignore
MANIFEST
README
setup.py
test-upload.py
urllib2_file.py

README

Python urllib2_file.py enable you to upload files using HTTP multipart/form-data

Install:

python setup.py test
python setup.py build
python setup.py install

Example:

import urllib2_files
import urllib2

data = { 'foo':         'bar',
         'form_name':    open("/lib/libc.so.1") }

(send something like: 'Content-Disposition: form-data; name="form_name"; filename="form_name";' )

Or if you want to specify a different filename:

data = {'foo':         'bar',
        'form_name':   {'fd':       open('/lib/libresolv.so.2',
                        'filename': 'libresolv.so'} }

(send something like: 'Content-Disposition: form-data; name="form_name"; filename="libresolv.so";' )

u = urllib2.urlopen('http://site.com/path/upload.php', data)

Tested with:
 python 2.3
 python 2.4
 python 2.5
Something went wrong with that request. Please try again.