[Tutor] File uploads perr HTTP

Remco Gerlich scarblac@pino.selwerd.nl
Thu, 22 Feb 2001 21:18:20 +0100


On Thu, Feb 22, 2001 at 11:32:58AM -0500, D-Man wrote:
> On Wed, Feb 21, 2001 at 08:19:07AM -0500, Sharriff Aina wrote:
> | Hi there!
> | 
> | can someone point me to a URL where I can RTFM "file uploads per HTTP in
> | Python" for dummies? I would be extremly nice if  someone posted a snippet
> | to the list, that would give me a push in the right direction.
> | 
> 
> I don't think this is generally possible/(easily) feasible.  AFAIK
> HTTP is intended for recieving. 

This is not true, HTTP does PUT requests as well as GET requests. It's just
that most servers have the option turned off. Assuming that he has it turned
on, it shouldn't be a problem.

With httplib, a snippet for putting index.html would look something like this:

import httplib
connection = httplib.HTTP("www.mywebserver.org",80)
connection.putrequest('PUT','/index.html')
connection.putheader('Content-type','text/html') # Guessing
connection.endheaders()
connection.send('<html></html>') # Insert your data here
connection.getreply() # Send everything, stop sending, get some reply

Something like this would work, but I haven't tried it out.

-- 
Remco Gerlich