curl-and-python

Re: how to POST file upload with pycurl

From: Kjetil Jacobsen <kjetilja_at_gmail.com>
Date: Fri, 2 Mar 2007 15:31:33 +0100

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
Received on 2007-03-02