xref: /curl/docs/libcurl/curl_mime_name.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_mime_name
5Section: 3
6Source: libcurl
7See-also:
8  - curl_mime_addpart (3)
9  - curl_mime_data (3)
10  - curl_mime_type (3)
11Protocol:
12  - HTTP
13  - IMAP
14  - SMTP
15Added-in: 7.56.0
16---
17
18# NAME
19
20curl_mime_name - set a mime part's name
21
22# SYNOPSIS
23
24~~~c
25#include <curl/curl.h>
26
27CURLcode curl_mime_name(curl_mimepart *part, const char *name);
28~~~
29
30# DESCRIPTION
31
32curl_mime_name(3) sets a mime part's name. This is the way HTTP form
33fields are named.
34
35*part* is the part's handle to assign a name to.
36
37*name* points to the null-terminated name string.
38
39The name string is copied into the part, thus the associated storage may
40safely be released or reused after call. Setting a part's name multiple times
41is valid: only the value set by the last call is retained. It is possible to
42reset the name of a part by setting *name* to NULL.
43
44# %PROTOCOLS%
45
46# EXAMPLE
47
48~~~c
49int main(void)
50{
51  curl_mime *mime;
52  curl_mimepart *part;
53
54  CURL *curl = curl_easy_init();
55  if(curl) {
56    /* create a mime handle */
57    mime = curl_mime_init(curl);
58
59    /* add a part */
60    part = curl_mime_addpart(mime);
61
62    /* give the part a name */
63    curl_mime_name(part, "shoe_size");
64  }
65}
66~~~
67
68# %AVAILABILITY%
69
70# RETURN VALUE
71
72CURLE_OK or a CURL error code upon failure.
73