cURL / Mailing Lists / curl-library / Single Mail

curl-library

HTTP posting a form consisting of two text fields and a file

From: Holger Rauch <Holger.Rauch_at_heitec.de>
Date: Tue, 10 Sep 2002 20:17:42 +0200 (CEST)

Hi!

I want to HTTP POST a form consisting of two text fields and a file. I
chose the following approach for this task and would like to know whether
it's correct or not. The two text fields are named "Sessionid" and
"Sessionkey".

The file is read correctly. That's what I noticed already. However, I'm
not sure whether my approach for setting the text fields is right.

Thanks in advance for any advice!

struct curl_slist* headers = NULL;
struct curl_httppost* post = NULL;
struct curl_httppost* last = NULL;
curl = curl_easy_init();
curl_easy_setopt( curl,
                  CURLOPT_URL,
                  "http://localhost/tamino/testdb/Area3" );
headers = curl_slist_append( headers, "Content-Type: text/xml" );
headers = curl_slist_append( headers, "Accept: text/xml" );
curl_formadd( &post, &last,
              CURLFORM_COPYNAME, "_Process",
              CURLFORM_FILECONTENT, "./testdoc.xml",
              CURLFORM_CONTENTHEADER, headers,
              CURLFORM_END );
curl_formadd( &post, &last,
              CURLFORM_COPYNAME, "Sessionid",
              CURLFORM_COPYCONTENTS, "16",
              CURLFORM_END );
curl_formadd( &post, &last,
              CURLFORM_COPYNAME, "Sessionkey",
              CURLFORM_COPYCONTENTS, "11932",
              CURLFORM_END );
curl_easy_setopt( curl,
                  CURLOPT_HTTPPOST,
                  post );
curl_easy_perform( curl );

Greetings,

        Holger

-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone? Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
Received on 2002-09-10