|
1 | 1 | Long: form |
2 | 2 | Short: F |
3 | 3 | Arg: <name=content> |
4 | | -Help: Specify HTTP multipart POST data |
5 | | -Protocols: HTTP |
| 4 | +Help: Specify multipart MIME data |
| 5 | +Protocols: HTTP SMTP IMAP |
6 | 6 | Mutexed: data head upload |
7 | 7 | --- |
8 | | -This lets curl emulate a filled-in form in which a user has pressed the submit |
9 | | -button. This causes curl to POST data using the Content-Type |
10 | | -multipart/form-data according to RFC 2388. This enables uploading of binary |
| 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 |
11 | 16 | files etc. To force the 'content' part to be a file, prefix the file name with |
12 | 17 | an @ sign. To just get the content part from a file, prefix the file name with |
13 | 18 | the symbol <. The difference between @ and < is then that @ makes a file get |
14 | 19 | attached in the post as a file upload, while the < makes a text field and just |
15 | 20 | get the contents for that text field from a file. |
16 | 21 |
|
17 | | -Example: to send an image to a server, where \&'profile' is the name of the |
18 | | -form-field to which portrait.jpg will be the input: |
| 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: |
19 | 24 |
|
20 | 25 | curl -F profile=@portrait.jpg https://example.com/upload.cgi |
21 | 26 |
|
|
49 | 54 | Note that if a filename/path is quoted by double-quotes, any double-quote |
50 | 55 | or backslash within the filename must be escaped by backslash. |
51 | 56 |
|
| 57 | +You can add custom headers to the field by setting headers=, like |
| 58 | + |
| 59 | + curl -F "submit=OK;headers=\\"X-submit-type: OK\\"" example.com |
| 60 | + |
| 61 | +or |
| 62 | + |
| 63 | + curl -F "submit=OK;headers=@headerfile" example.com |
| 64 | + |
| 65 | +The headers= keyword may appear more that once and above notes about quoting |
| 66 | +apply. When headers are read from a file, Empty lines and lines starting |
| 67 | +with '#' are comments and ignored; each header can be folded by splitting |
| 68 | +between two words and starting the continuation line with a space; embedded |
| 69 | +carriage-returns and trailing spaces are stripped. |
| 70 | +Here is an example of a header file contents: |
| 71 | + |
| 72 | + # This file contain two headers. |
| 73 | +.br |
| 74 | + X-header-1: this is a header |
| 75 | + |
| 76 | + # The following header is folded. |
| 77 | +.br |
| 78 | + X-header-2: this is |
| 79 | +.br |
| 80 | + another header |
| 81 | + |
| 82 | + |
| 83 | +To support sending multipart mail messages, the syntax is extended as follows: |
| 84 | +.br |
| 85 | +- name can be omitted: the equal sign is the first character of the argument, |
| 86 | +.br |
| 87 | +- if data starts with '(', this signals to start a new multipart: it can be |
| 88 | +followed by a content type specification. |
| 89 | +.br |
| 90 | +- a multipart can be terminated with a '=)' argument. |
| 91 | + |
| 92 | +Example: the following command sends an SMTP mime e-mail consisting in an |
| 93 | +inline part in two alternative formats: plain text and HTML. It attaches a |
| 94 | +text file: |
| 95 | + |
| 96 | + curl -F '=(;type=multipart/alternative' \\ |
| 97 | +.br |
| 98 | + -F '=plain text message' \\ |
| 99 | +.br |
| 100 | + -F '= <body>HTML message</body>;type=text/html' \\ |
| 101 | +.br |
| 102 | + -F '=)' -F '=@textfile.txt' ... smtp://example.com |
| 103 | + |
52 | 104 | See further examples and details in the MANUAL. |
53 | 105 |
|
54 | 106 | This option can be used multiple times. |
0 commit comments