Up
Extending urllib2
urllib2 can not (at least up to python 2.3 and 2.4) send files using POST and multipart/form-data encoding.
(simulating a FORM with TYPE="text" TYPE="file")
Download:

2006-09-22: urllib2_file-0.2.0.py
- UTF-8 filenames are now allowed (Eli Golovinsky)
- File object is no more mandatory, Object only needs to have seek() read() attributes (Eli Golovinsky)

2006-09-07: urllib2_file-0.1.0.py
- upload is does using chunks (Adam Ambrose)

Example
import urllib2_file
import urllib2

data = {'name': 'value',
        'file':  open('/etc/services')
       }
data2 = [ 'the bus,     'felt near Coroico',
          'userfile', open('/home/foo/bar.png')
        ]
urllib2.urlopen('http://site.com/script_upload.php', data)
Example2

Example: upload a file to Gallery (http://gallery.menalto.com)
test.py

Ideas from:

posting multipart/form-data in Python:
timeoutsocket.py: overriding Python socket API:

Valid XHTML 1.0! Valid CSS!

$Id: urllib2_multipart.html,v 1.7 2006-09-22 09:53:02 dakol Exp $