Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: How to upload a file with httplib?

Reply
Thread Tools

Re: How to upload a file with httplib?

 
 
John J. Lee
Guest
Posts: n/a
 
      06-27-2003
"Hank Hu" <> writes:

> I'm writing a prototype with python and need upload a zip file to a web
> server. Any idea?


http://wwwsearch.sourceforge.net/ClientForm/

At your own risk, since file upload is poorly tested ATM. You'd need
this version:

http://wwwsearch.sourceforge.net/Cli...-0.1.3a.tar.gz

IIRC, there's not yet a method on HTMLForm, so you need to use the
control directly:

import urllib2
from ClientForm import ParseResponse

forms = ParseResponse(urllib2.urlopen("http://www.example.com/"))
form = forms[0]
ctrl = form.find_control(type="file")
# note multi-file upload not implemented yet
# name and content_type args. to add_file are optional
ctrl.add_file(open("my.zip"), name="my.zip")
response2 = urllib.urlopen(form.click())


John
 
Reply With Quote
 
 
 
 
hh
Guest
Posts: n/a
 
      06-27-2003
John,

thanks a lot, I will try it.

Hank Hu


"John J. Lee" <> ???? news:...
> "Hank Hu" <> writes:
>
> > I'm writing a prototype with python and need upload a zip file to a web
> > server. Any idea?

>
> http://wwwsearch.sourceforge.net/ClientForm/
>
> At your own risk, since file upload is poorly tested ATM. You'd need
> this version:
>
> http://wwwsearch.sourceforge.net/Cli...-0.1.3a.tar.gz
>
> IIRC, there's not yet a method on HTMLForm, so you need to use the
> control directly:
>
> import urllib2
> from ClientForm import ParseResponse
>
> forms = ParseResponse(urllib2.urlopen("http://www.example.com/"))
> form = forms[0]
> ctrl = form.find_control(type="file")
> # note multi-file upload not implemented yet
> # name and content_type args. to add_file are optional
> ctrl.add_file(open("my.zip"), name="my.zip")
> response2 = urllib.urlopen(form.click())
>
>
> John



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
File upload from client application (non-form based upload) stuart@microsoft.com Python 1 11-25-2006 12:14 AM
Upload a file without file Upload control - ASP.Net =?Utf-8?B?U2FyYXY=?= ASP .Net 3 08-03-2005 01:09 AM
How to detect sizeof upload in order to show status of browser file upload? Heather Fraser Java 0 07-05-2004 12:35 AM
Upload Excel with Macros using HTML File Upload Prakash ASP General 3 11-12-2003 04:26 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57