DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Upload File With Http Client (multipart/form-data)

09.16.2005
| 29345 views |
  • submit to reddit
        
def post_multipart(host, selector, fields, files):
    """
    Post fields and files to an http host as multipart/form-data.
    fields is a sequence of (name, value) elements for regular form fields.
    files is a sequence of (name, filename, value) elements for data to be uploaded as files
    Return the server's response page.
    """
See the rest of the implementation <a href=http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/146306>here</a>