CURLOPT_MIMEPOST.3: add an (inline) example

Reported-by: Jay Satiro
Bug: https://github.com/curl/curl/pull/9637#issuecomment-1268070723

Closes #9649
This commit is contained in:
Daniel Stenberg 2022-10-05 10:02:13 +02:00
parent 14aa9b193c
commit 5299301a9b
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View 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