xref: /curl/docs/libcurl/curl_formfree.md (revision 5a488251)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: curl_formfree
5Section: 3
6Source: libcurl
7See-also:
8  - curl_formadd (3)
9  - curl_mime_free (3)
10  - curl_mime_init (3)
11Protocol:
12  - HTTP
13Added-in: 7.1
14---
15
16# NAME
17
18curl_formfree - free a previously build multipart form post chain
19
20# SYNOPSIS
21
22~~~c
23#include <curl/curl.h>
24
25void curl_formfree(struct curl_httppost *form);
26~~~
27
28# DESCRIPTION
29
30This function is deprecated. Do not use. See curl_mime_init(3) instead!
31
32curl_formfree() is used to clean up data previously built/appended with
33curl_formadd(3). This must be called when the data has been used, which
34typically means after curl_easy_perform(3) has been called.
35
36The pointer to free is the same pointer you passed to the
37CURLOPT_HTTPPOST(3) option, which is the *firstitem* pointer from
38the curl_formadd(3) invoke(s).
39
40**form** is the pointer as returned from a previous call to
41curl_formadd(3) and may be NULL.
42
43Passing in a NULL pointer in *form* makes this function return immediately
44with no action.
45
46# %PROTOCOLS%
47
48# EXAMPLE
49
50~~~c
51int main(void)
52{
53  CURL *curl = curl_easy_init();
54  if(curl) {
55    struct curl_httppost *formpost;
56    struct curl_httppost *lastptr;
57
58    /* Fill in a file upload field */
59    curl_formadd(&formpost,
60                 &lastptr,
61                 CURLFORM_COPYNAME, "file",
62                 CURLFORM_FILE, "nice-image.jpg",
63                 CURLFORM_END);
64
65    curl_easy_setopt(curl, CURLOPT_HTTPPOST, formpost);
66
67    curl_easy_perform(curl);
68
69    /* then cleanup the formpost chain */
70    curl_formfree(formpost);
71  }
72}
73~~~
74
75# DEPRECATED
76
77Deprecated in 7.56.0.
78
79# %AVAILABILITY%
80
81# RETURN VALUE
82
83None
84