cURL / Mailing Lists / curl-library / Single Mail

curl-library

formadd question

From: Andrés García <fandom_at_retemail.es>
Date: Mon, 29 Oct 2001 00:17:58 +0100

Hi,

I have been playing with the new formadd function, doing something like:

int main(int argc, char *argv[]) {
    CURL *curl;

    struct HttpPost *formpost=NULL;
    struct HttpPost *lastptr=NULL;
    struct curl_forms forms[3];

    forms[0].option=CURLFORM_FILE;
    forms[0].value=strdup("postit3.c");
    forms[1].option=CURLFORM_FILE;
    forms[1].value=strdup("postit2.c");
    forms[2].option=CURLFORM_END;

    curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "Ficheros",
            CURLFORM_ARRAY, forms, CURLFORM_END);
    curl_formadd(&formpost, &lastptr, CURLFORM_COPYNAME, "submit",
            CURLFORM_COPYCONTENTS, "send", CURLFORM_END);
    curl = curl_easy_init();
    curl_easy_setopt(curl, CURLOPT_URL, "http://127.0.0.1/cgi-bin/post1.tcl");
    curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
    curl_easy_perform(curl);
    curl_easy_cleanup(curl);
    curl_formfree(formpost);

    return 0;
}

I was expecting both files to be sent to the CGI script, yet  with version
7.9.1-pre5 only the first one is sent.

Am I doing something wrong or is this a bug?

On the other hand, in the formadd man page it says:

      forms[2].value  = CURLFORM_END;
      /* no option needed for the end marker */

Shouldn't that be: forms[2].option=CURLFORM_END; ?

Andres
Received on 2001-10-29