cURL / Mailing Lists / curl-library / Single Mail

curl-library

How do I use multipart form posts?

From: Jonathan Wallace <jwallace_at_livetechnology.com>
Date: Fri, 26 Mar 2010 13:52:52 -0400

I can't figure out how to do it. I need the output to look like this:

Various headers and cookies
---+-+-*ThisBoundaryStringCanBeAnythingWhichDoes77028NotAppearInTheMessage*-+-+-
Content-Disposition: form-data; name="aSetValue"; filename="sizetest.png"

?PNG

???
IHDR???
???
???r??|???sBIT??O????sRGB???????gAMA????
?a???
pHYs???????+????IDAT(S??=o?0?_?9|,U?D?@?T]:?S?GP?B?Z?*?), EJ??9g?z??,????Y??zS??z?=????0XLF?jn??a?{?s^'C?uP???}??"fB?{/?IFNJ?????$?a?n?>?M???(?????>%???
$?*????uq?[V?^?OH??
??O??1fYP?^?M?????s?8?~?#6Y?????????g???/???]??????IEND?B`?
---+-+-*ThisBoundaryStringCanBeAnythingWhichDoes77028NotAppearInTheMessage*-+-+---

Here's what I've got so far:
        struct curl_httppost * post = NULL;
        struct curl_httppost * last = NULL;
        curl_formadd(&post, &last,
                     CURLFORM_COPYNAME, "aSetValue",
                     CURLFORM_FILENAME, file.c_str(),
                     CURLFORM_END);
        curl_easy_setopt(curl, CURLOPT_HTTPPOST, post);

But that sends only the headers that I define elsewhere with a
Content-Length of 0.

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2010-03-26