blob: 87a7d07663e5da1e128634c2a75a78490eec43b4 [file] [log] [blame]
yuezonghe824eb0c2024-06-27 02:32:26 -07001Long: form
2Short: F
3Arg: <name=content>
4Help: Specify HTTP multipart POST data
5Protocols: HTTP
6Mutexed: data head upload
7---
8This lets curl emulate a filled-in form in which a user has pressed the submit
9button. This causes curl to POST data using the Content-Type
10multipart/form-data according to RFC 2388. This enables uploading of binary
11files etc. To force the 'content' part to be a file, prefix the file name with
12an @ sign. To just get the content part from a file, prefix the file name with
13the symbol <. The difference between @ and < is then that @ makes a file get
14attached in the post as a file upload, while the < makes a text field and just
15get the contents for that text field from a file.
16
17Example: to send an image to a server, where \&'profile' is the name of the
18form-field to which portrait.jpg will be the input:
19
20 curl -F profile=@portrait.jpg https://example.com/upload.cgi
21
22To read content from stdin instead of a file, use - as the filename. This goes
23for both @ and < constructs. Unfortunately it does not support reading the
24file from a named pipe or similar, as it needs the full size before the
25transfer starts.
26
27You can also tell curl what Content-Type to use by using 'type=', in a manner
28similar to:
29
30 curl -F "web=@index.html;type=text/html" example.com
31
32or
33
34 curl -F "name=daniel;type=text/foo" example.com
35
36You can also explicitly change the name field of a file upload part by setting
37filename=, like this:
38
39 curl -F "file=@localfile;filename=nameinpost" example.com
40
41If filename/path contains ',' or ';', it must be quoted by double-quotes like:
42
43 curl -F "file=@\\"localfile\\";filename=\\"nameinpost\\"" example.com
44
45or
46
47 curl -F 'file=@"localfile";filename="nameinpost"' example.com
48
49Note that if a filename/path is quoted by double-quotes, any double-quote
50or backslash within the filename must be escaped by backslash.
51
52See further examples and details in the MANUAL.
53
54This option can be used multiple times.