cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: how to do multi-part formposts

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 7 Jun 2002 11:43:53 +0200 (MET DST)

On Thu, 6 Jun 2002, Combes, Chris M. wrote:

> What I need to do is to upload at least two separate files.
>
> The examples don't state clearly how to do this.

No. The examples don't cover that, but I hoped that the curl_formadd man page
was possible to fill in the blanks.

> Content-Disposition: form-data; name="file"; filename=""
>
> <data>
>
> However, if I use CURLFORM_FILECONTENT it only loads ascii data as a value
> to a parameter, and does not add the second "filename" which contains the
> actual filename such as "image.png", and then push the <data> that will be
> parsed on the server.

Right. That is so because CURLFORM_FILECONTENT was meant and designed as a
method to provide content data in exchange for using CURLFORM_PTRCONTENTS or
CURLFORM_COPYCONTENTS. It just means you create a command "part" with
contents read from the specified file.

To make a file-part in the manner you want, CURLFORM_FILE is your friend.

> The tutorial says to use the following for binary data:
>
> curl_formadd(&post, &last,
> CURLFORM_COPYNAME, "logotype-image",
> CURLFORM_FILECONTENT, "curl.png", CURLFORM_END);

It does? Then it is wrong. (Where does it say this?) The code should be:

  curl_formadd(&post, &last,
               CURLFORM_COPYNAME, "logotype-image",
               CURLFORM_FILE, "curl.png", CURLFORM_END);

I hope this helps.

-- 
  Daniel Stenberg
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
Received on 2002-06-07