curl-and-python

Re: how to POST file upload with pycurl

From: PoisoneR <poisonertmp_at_gmail.com>
Date: Fri, 2 Mar 2007 18:16:23 +0200

hi,
that is what i looked after my post.
And I send a reply but it is not received.

10x.

On 3/2/07, Kjetil Jacobsen <kjetilja_at_gmail.com> wrote:
> hi,
>
> look at the pycurl tests in the distribution as they might help, for
> instance this one:
>
> http://pycurl.cvs.sourceforge.net/*checkout*/pycurl/pycurl/tests/test_post2.py?revision=1.13&content-type=text%2Fplain
>
> regards,
> - kjetil
>
> On 3/2/07, PoisoneR <poisonertmp_at_gmail.com> wrote:
> > Hi,
> > I am trying to submit file via HTTP POST.
> > But I can't find any examples in the net.
> > I tried somethin like this
> >
> > def sendupload():
> > c = pycurl.Curl()
> > c.setopt(c.USERAGENT, ua)
> > url = 'http://localhost/post.php'
> > c.setopt(c.POST, 1)
> > c.setopt(c.URL, url)
> > f = open('clip.3gp', 'rb')
> > c.setopt(c.FORM_FILE, f)
> > fc = 'cookie.txt'
> > c.setopt(c.COOKIEFILE, fc)
> > c.setopt(c.COOKIEJAR, fc)
> > f = open('sendupload.html', 'wb')
> > c.setopt(c.WRITEDATA, f)
> > c.setopt(c.VERBOSE, 1)
> > c.perform()
> > c.close()
> >
> > but it doesn't work
> >
> > c.setopt(c.FORM_FILE, f)
> > TypeError: files are not supported for this option
> >
> > i tried and with filename string instead file object, but is the same.
> > What variable type this wants?
> > _______________________________________________
> > http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
> >
> _______________________________________________
> http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2007-03-02