cURL / Mailing Lists / curl-library / Single Mail

curl-library

Multipart Formpost: Strange results

From: Michael Becker <space.monkey_at_web.de>
Date: Tue, 20 Apr 2004 18:44:35 +0200

Hello!

 From the examples on curl.haxx.se, I derived this source code:

        curl_formadd(&post, &last,
                                 CURLFORM_COPYNAME, "uplid",
                                 CURLFORM_COPYCONTENTS, "123"
                                 CURLFORM_END);
        
        curl_formadd(&post, &last,
                                 CURLFORM_COPYNAME, "uploadfile",
                                 CURLFORM_FILE, "/Users/myself/image.jpg",
                                 CURLFORM_END);

        curl_formadd(&post, &last,
                                 CURLFORM_COPYNAME, "filename",
                                 CURLFORM_COPYCONTENTS, "/Users/myself/image.jpg",
                                 CURLFORM_END);

Which produces the following HTTP output:

------------------------------df0e31447f6f
Content-Disposition: form-data; name="uplid"

123
------------------------------df0e31447f6f
Content-Disposition: form-data; name="uploadfile";
filename="/Users/myself/image.jpg"
Content-Type: image/jpeg

[ image binary data ]

Now my question is: The source code looks as if it would add a third
MIME-part for "filename" (e.g. "Content-Disposition:form-data;
name="filename" etc.). Why doesn't it? :-) (Besides, I am really
stunned that curl seems to detect the "image/jpeg" on its own)

Is there any pattern/reason/documentation for this behaviour?

Bye,
Michael
Received on 2004-04-20