curl-and-python
Re: how to POST file upload with pycurl
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:
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