[Tutor] Uploading a file (non-form)
Timo
timomlists at gmail.com
Sun May 30 13:42:02 CEST 2010
Hello,
I am searching and searching and searching and ... Still haven't found the
solution.
Basicly, I want to upload a file to my http server. The user shouldn't have
to do anything for this, so a userform on my webpage is a no-go.
For just text, I managed to do it with a form, but fill it in automaticly
through the code. Like:
Clientside:
form = urllib.urlencode([("text", "Some example text")])
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(None))
opener.open(urllib2.Request(url, None, USER_AGENT), form)
Serverside:
form = cgi.FieldStorage()
text = form['text'].value
Now I can use 'text' on the server, for mailing etc. But I really can't
manage to do this with a file.
Anyone can give me a helping hand here?
Cheers,
Timo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100530/455c92c5/attachment.html>
More information about the Tutor
mailing list