1--- 2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_mime_type 5Section: 3 6Source: libcurl 7See-also: 8 - curl_mime_addpart (3) 9 - curl_mime_data (3) 10 - curl_mime_name (3) 11Protocol: 12 - HTTP 13 - IMAP 14 - SMTP 15--- 16 17# NAME 18 19curl_mime_type - set a mime part's content type 20 21# SYNOPSIS 22 23~~~c 24#include <curl/curl.h> 25 26CURLcode curl_mime_type(curl_mimepart *part, const char *mimetype); 27~~~ 28 29# DESCRIPTION 30 31curl_mime_type(3) sets a mime part's content type. 32 33*part* is the part's handle to assign the content type to. 34 35*mimetype* points to the null-terminated file mime type string; it may be 36set to NULL to remove a previously attached mime type. 37 38The mime type string is copied into the part, thus the associated storage may 39safely be released or reused after call. Setting a part's type multiple times 40is valid: only the value set by the last call is retained. 41 42In the absence of a mime type and if needed by the protocol specifications, 43a default mime type is determined by the context: 44 45- If set as a custom header, use this value. 46 47- application/form-data for an HTTP form post. 48 49- If a remote filename is set, the mime type is taken from the filename 50extension, or application/octet-stream by default. 51 52- For a multipart part, multipart/mixed. 53 54- text/plain in other cases. 55 56# EXAMPLE 57 58~~~c 59int main(void) 60{ 61 curl_mime *mime; 62 curl_mimepart *part; 63 64 CURL *curl = curl_easy_init(); 65 if(curl) { 66 /* create a mime handle */ 67 mime = curl_mime_init(curl); 68 69 /* add a part */ 70 part = curl_mime_addpart(mime); 71 72 /* get data from this file */ 73 curl_mime_filedata(part, "image.png"); 74 75 /* content-type for this part */ 76 curl_mime_type(part, "image/png"); 77 78 /* set name */ 79 curl_mime_name(part, "image"); 80} 81} 82~~~ 83 84# AVAILABILITY 85 86As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0. 87 88# RETURN VALUE 89 90CURLE_OK or a CURL error code upon failure. 91