xref: /curl/docs/cmdline-opts/data-urlencode.md (revision 3040971d)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Long: data-urlencode
5Arg: <data>
6Help: HTTP POST data URL encoded
7Protocols: HTTP
8Added: 7.18.0
9Category: http post upload
10Multi: append
11See-also:
12  - data
13  - data-raw
14Example:
15  - --data-urlencode name=val $URL
16  - --data-urlencode =encodethis $URL
17  - --data-urlencode name@file $URL
18  - --data-urlencode @fileonly $URL
19---
20
21# `--data-urlencode`
22
23Post data, similar to the other --data options with the exception that this
24performs URL-encoding.
25
26To be CGI-compliant, the \<data\> part should begin with a *name* followed by
27a separator and a content specification. The \<data\> part can be passed to
28curl using one of the following syntaxes:
29
30## content
31URL-encode the content and pass that on. Just be careful so that the content
32does not contain any `=` or `@` symbols, as that makes the syntax match one of
33the other cases below.
34
35## =content
36URL-encode the content and pass that on. The preceding `=` symbol is not
37included in the data.
38
39## name=content
40URL-encode the content part and pass that on. Note that the name part is
41expected to be URL-encoded already.
42
43## @filename
44load data from the given file (including any newlines), URL-encode that data
45and pass it on in the POST. Using `@-` makes curl read the data from stdin.
46
47## name@filename
48load data from the given file (including any newlines), URL-encode that data
49and pass it on in the POST. The name part gets an equal sign appended,
50resulting in *name=urlencoded-file-content*. Note that the name is expected to
51be URL-encoded already.
52