1CURLOPT_MIMEPOST(3) curl_easy_setopt options CURLOPT_MIMEPOST(3)
2
3
4
6 CURLOPT_MIMEPOST - send data from mime structure
7
9 #include <curl/curl.h>
10
11 curl_mime *mime;
12
13 CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIMEPOST, mime);
14
16 Pass a mime handle previously obtained from curl_mime_init(3).
17
18 This setting is supported by the HTTP protocol to post forms and by the
19 SMTP and IMAP protocols to provide the email data to send/upload.
20
21 This option is the preferred way of posting an HTTP form, replacing and
22 extending the CURLOPT_HTTPPOST(3) option.
23
25 HTTP, SMTP, IMAP.
26
28 curl_mime *multipart = curl_mime_init(handle);
29 curl_mimepart *part = curl_mime_addpart(multipart);
30 curl_mime_name(part, "name");
31 curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED);
32 part = curl_mime_addpart(multipart);
33 curl_mime_name(part, "project");
34 curl_mime_data(part, "curl", CURL_ZERO_TERMINATED);
35 part = curl_mime_addpart(multipart);
36 curl_mime_name(part, "logotype-image");
37 curl_mime_filedata(part, "curl.png");
38
39 /* Set the form info */
40 curl_easy_setopt(handle, CURLOPT_MIMEPOST, multipart);
41
42 curl_easy_perform(handle); /* post away! */
43
44 curl_mime_free(multipart); /* free the post data */
45
47 Added in 7.56.0
48
50 This will return CURLE_OK.
51
53 curl_mime_init(3)
54
55
56
57libcurl 8.0.1 January 02, 2023 CURLOPT_MIMEPOST(3)