]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
CURLOPT_MIMEPOST.3: add an (inline) example
authorDaniel Stenberg <daniel@haxx.se>
Wed, 5 Oct 2022 08:02:13 +0000 (10:02 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Wed, 5 Oct 2022 14:04:08 +0000 (16:04 +0200)
Reported-by: Jay Satiro
Bug: https://github.com/curl/curl/pull/9637#issuecomment-1268070723

Closes #9649

docs/libcurl/opts/CURLOPT_MIMEPOST.3

index 6560e2b3696a1522296a36929032792988b5f005..5995991d7df41f0346a315e8dac7d82231645ba3 100644 (file)
@@ -43,9 +43,25 @@ extending the deprecated \fICURLOPT_HTTPPOST(3)\fP option.
 .SH PROTOCOLS
 HTTP, SMTP, IMAP.
 .SH EXAMPLE
-Using this option implies the use of several mime structure building
-functions: see https://curl.se/libcurl/c/smtp-mime.html for a complete
-example.
+.nf
+ curl_mime *multipart = curl_mime_init(handle);
+ curl_mimepart *part = curl_mime_addpart(multipart);
+ curl_mime_name(part, "name");
+ curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED);
+ part = curl_mime_addpart(multipart);
+ curl_mime_name(part, "project");
+ curl_mime_data(part, "curl", CURL_ZERO_TERMINATED);
+ part = curl_mime_addpart(multipart);
+ curl_mime_name(part, "logotype-image");
+ curl_mime_filedata(part, "curl.png");
+
+ /* Set the form info */
+ curl_easy_setopt(handle, CURLOPT_MIMEPOST, multipart);
+
+ curl_easy_perform(handle); /* post away! */
+
+ curl_mime_free(multipart); /* free the post data */
+.fi
 .SH AVAILABILITY
 Added in 7.56.0
 .SH RETURN VALUE