http file upload from Python (multipart/formdata) how-to?

Robert k.robert at
Fri Sep 27 16:17:38 EDT 2002

"Tim Roberts" <timr at> schrieb im Newsbeitrag
news:ujp7pu4osgoagpnqr4ls727cibm2ua5jq1 at
> "Robert" <k.robert at> wrote:
> >want to upload file data (multipart formdata) - same as upload from
> >web-browser <input type=file ..>
> >
> >urllib.urlencode  + urlopen takes only simple name/value tuples
> >
> >how do I render multipart formdata ?
> I guess you will have to generate the HTTP/MIME headers and send the file
> in your own code.  See RFC 1867.
> Are you trying to interface with a web form that already exists, or are
> just trying to do a file transfer from one machine to another?
> --
> - Tim Roberts, timr at
>   Providenza & Boekelheide, Inc.

yes think I have to render the RFC1867 HTTP/MIME headers manually and put it
as 'data' parameter to urlopen.

found no python code to do that upon the last google session. only strange
perl hieroglyphs $%()%$//%=?!=... and I have no archeologist ;-)

so I am still too lazy to read and implement the RFC and hope that somebody
already had the same problem


More information about the Python-list mailing list