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