1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: CURLOPT_MIMEPOST 5Section: 3 6Source: libcurl 7See-also: 8 - CURLOPT_HTTPPOST (3) 9 - CURLOPT_POSTFIELDS (3) 10 - CURLOPT_PUT (3) 11 - curl_mime_init (3) 12Protocol: 13 - HTTP 14 - SMTP 15 - IMAP 16--- 17 18# NAME 19 20CURLOPT_MIMEPOST - send data from mime structure 21 22# SYNOPSIS 23 24~~~c 25#include <curl/curl.h> 26 27curl_mime *mime; 28 29CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIMEPOST, mime); 30~~~ 31 32# DESCRIPTION 33 34Pass a mime handle previously obtained from curl_mime_init(3). 35 36This setting is supported by the HTTP protocol to post forms and by the 37SMTP and IMAP protocols to provide the email data to send/upload. 38 39This option is the preferred way of posting an HTTP form, replacing and 40extending the CURLOPT_HTTPPOST(3) option. 41 42When setting CURLOPT_MIMEPOST(3) to NULL, libcurl resets the request 43type for HTTP to the default to disable the POST. Typically that would mean it 44is reset to GET. Instead you should set a desired request method explicitly. 45 46# EXAMPLE 47 48~~~c 49int main(void) 50{ 51 CURL *curl = curl_easy_init(); 52 if(curl) { 53 curl_mime *multipart = curl_mime_init(curl); 54 if(multipart) { 55 curl_mimepart *part = curl_mime_addpart(multipart); 56 curl_mime_name(part, "name"); 57 curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED); 58 part = curl_mime_addpart(multipart); 59 curl_mime_name(part, "project"); 60 curl_mime_data(part, "curl", CURL_ZERO_TERMINATED); 61 part = curl_mime_addpart(multipart); 62 curl_mime_name(part, "logotype-image"); 63 curl_mime_filedata(part, "curl.png"); 64 65 /* Set the form info */ 66 curl_easy_setopt(curl, CURLOPT_MIMEPOST, multipart); 67 68 curl_easy_perform(curl); /* post away! */ 69 curl_mime_free(multipart); /* free the post data */ 70 } 71 } 72} 73~~~ 74 75# AVAILABILITY 76 77Added in 7.56.0 78 79# RETURN VALUE 80 81This returns CURLE_OK. 82