How to upload a file using http protocol
Steve Holden
sholden at holdenweb.com
Fri Sep 27 09:59:49 EDT 2002
> "A" <export at hope.cz> wrote in message
> news:mailman.1032552637.6156.python-list at python.org...
> > Hi,
> > Does anyone know how to upload a file through HTTP protocol?Is that a
> possible?
> > Thank you for help.
> > ladislav
> >
"DeepBleu" <DeepBleu at DeepBleu.org> top-posted ...
> Yes it is. Assume that the user has to enter the file name (with the
path)
> on a form. You use File type form element which allows the user to browse
> for the file.
Technically, what you need is an <INPUT> element with the TYPE="FILE"
attribute. You may also need to make sure that you have the correct MIME
type (Content-Type: multipart/form-data). You may want to read
http://www.ietf.org/rfc/rfc2388.txt
to get the details absuolutely right, but it might be easier just to try a
few options until it works...
> Using CGI module, and a Submit button (or some javascript with a submit
> function) this form element has a KEY. The VALUE of this key is the Byte
> content of the file, NOT the file name. Thus, by using the VALUE KEY, the
> server is actually receiving the byte content. From there on, the sky is
> the limit.
> DeepBleu
>
Read the CGI module's documentation to determin how to read the content.
regards
Steve
More information about the Python-list
mailing list