Skip to content

nesies/urllib2_file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Extend urllib2 to support HTTP POST file upload

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published