• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 Long: form
2 Short: F
3 Arg: <name=content>
4 Help: Specify multipart MIME data
5 Protocols: HTTP SMTP IMAP
6 Mutexed: data head upload
7 ---
8 For HTTP protocol family, this lets curl emulate a filled-in form in which a
9 user has pressed the submit button. This causes curl to POST data using the
10 Content-Type multipart/form-data according to RFC 2388.
11 
12 For SMTP and IMAP protocols, this is the mean to compose a multipart mail
13 message to transmit.
14 
15 This enables uploading of binary
16 files etc. To force the 'content' part to be a file, prefix the file name with
17 an @ sign. To just get the content part from a file, prefix the file name with
18 the symbol <. The difference between @ and < is then that @ makes a file get
19 attached in the post as a file upload, while the < makes a text field and just
20 get the contents for that text field from a file.
21 
22 Example: to send an image to an HTTP server, where \&'profile' is the name of
23 the form-field to which portrait.jpg will be the input:
24 
25  curl -F profile=@portrait.jpg https://example.com/upload.cgi
26 
27 To read content from stdin instead of a file, use - as the filename. This goes
28 for both @ and < constructs. If stdin is not attached to a regular file, it is
29 buffered first to determine its size and allow a possible resend. Defining a
30 part's data from a named non-regular file (such as a named pipe or similar) is
31 unfortunately not subject to buffering and will be effectively read at
32 transmission time; since the full size is unknown before the transfer starts,
33 data is sent as chunks by HTTP and rejected by IMAP.
34 
35 You can also tell curl what Content-Type to use by using 'type=', in a manner
36 similar to:
37 
38  curl -F "web=@index.html;type=text/html" example.com
39 
40 or
41 
42  curl -F "name=daniel;type=text/foo" example.com
43 
44 You can also explicitly change the name field of a file upload part by setting
45 filename=, like this:
46 
47  curl -F "file=@localfile;filename=nameinpost" example.com
48 
49 If filename/path contains ',' or ';', it must be quoted by double-quotes like:
50 
51  curl -F "file=@\\"localfile\\";filename=\\"nameinpost\\"" example.com
52 
53 or
54 
55  curl -F 'file=@"localfile";filename="nameinpost"' example.com
56 
57 Note that if a filename/path is quoted by double-quotes, any double-quote
58 or backslash within the filename must be escaped by backslash.
59 
60 Quoting must also be applied to non-file data if it contains semicolons,
61 leading/trailing spaces or leading double quotes:
62 
63  curl -F 'colors="red; green; blue";type=text/x-myapp' example.com
64 
65 You can add custom headers to the field by setting headers=, like
66 
67   curl -F "submit=OK;headers=\\"X-submit-type: OK\\"" example.com
68 
69 or
70 
71   curl -F "submit=OK;headers=@headerfile" example.com
72 
73 The headers= keyword may appear more that once and above notes about quoting
74 apply. When headers are read from a file, Empty lines and lines starting
75 with '#' are comments and ignored; each header can be folded by splitting
76 between two words and starting the continuation line with a space; embedded
77 carriage-returns and trailing spaces are stripped.
78 Here is an example of a header file contents:
79 
80   # This file contain two headers.
81 .br
82   X-header-1: this is a header
83 
84   # The following header is folded.
85 .br
86   X-header-2: this is
87 .br
88    another header
89 
90 
91 To support sending multipart mail messages, the syntax is extended as follows:
92 .br
93 - name can be omitted: the equal sign is the first character of the argument,
94 .br
95 - if data starts with '(', this signals to start a new multipart: it can be
96 followed by a content type specification.
97 .br
98 - a multipart can be terminated with a '=)' argument.
99 
100 Example: the following command sends an SMTP mime e-mail consisting in an
101 inline part in two alternative formats: plain text and HTML. It attaches a
102 text file:
103 
104  curl -F '=(;type=multipart/alternative' \\
105 .br
106          -F '=plain text message' \\
107 .br
108          -F '= <body>HTML message</body>;type=text/html' \\
109 .br
110       -F '=)' -F '=@textfile.txt' ...  smtp://example.com
111 
112 Data can be encoded for transfer using encoder=. Available encodings are
113 \fIbinary\fP and \fI8bit\fP that do nothing else than adding the corresponding
114 Content-Transfer-Encoding header, \fI7bit\fP that only rejects 8-bit characters
115 with a transfer error, \fIquoted-printable\fP and \fIbase64\fP that encodes
116 data according to the corresponding schemes, limiting lines length to
117 76 characters.
118 
119 Example: send multipart mail with a quoted-printable text message and a
120 base64 attached file:
121 
122  curl -F '=text message;encoder=quoted-printable' \\
123 .br
124       -F '=@localfile;encoder=base64' ... smtp://example.com
125 
126 See further examples and details in the MANUAL.
127 
128 This option can be used multiple times.
129