mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 17:31:46 -05:00
form.d: rephrased somewhat, added two example command lines
This commit is contained in:
parent
23713645d4
commit
93e7a6ffd1
@ -12,25 +12,35 @@ Content-Type multipart/form-data according to RFC 2388.
|
|||||||
For SMTP and IMAP protocols, this is the mean to compose a multipart mail
|
For SMTP and IMAP protocols, this is the mean to compose a multipart mail
|
||||||
message to transmit.
|
message to transmit.
|
||||||
|
|
||||||
This enables uploading of binary
|
This enables uploading of binary files etc. To force the 'content' part to be
|
||||||
files etc. To force the 'content' part to be a file, prefix the file name with
|
a file, prefix the file name with an @ sign. To just get the content part from
|
||||||
an @ sign. To just get the content part from a file, prefix the file name with
|
a file, prefix the file name with the symbol <. The difference between @ and <
|
||||||
the symbol <. The difference between @ and < is then that @ makes a file get
|
is then that @ makes a file get attached in the post as a file upload, while
|
||||||
attached in the post as a file upload, while the < makes a text field and just
|
the < makes a text field and just get the contents for that text field from a
|
||||||
get the contents for that text field from a file.
|
file.
|
||||||
|
|
||||||
Example: to send an image to an HTTP server, where \&'profile' is the name of
|
Tell curl to read content from stdin instead of a file by using - as
|
||||||
the form-field to which portrait.jpg will be the input:
|
filename. This goes for both @ and < constructs. When stdin is used, the
|
||||||
|
contents is buffered in memory first by curl to determine its size and allow a
|
||||||
|
possible resend. Defining a part's data from a named non-regular file (such
|
||||||
|
as a named pipe or similar) is unfortunately not subject to buffering and will
|
||||||
|
be effectively read at transmission time; since the full size is unknown
|
||||||
|
before the transfer starts, such data is sent as chunks by HTTP and rejected
|
||||||
|
by IMAP.
|
||||||
|
|
||||||
|
Example: send an image to an HTTP server, where \&'profile' is the name of the
|
||||||
|
form-field to which the file portrait.jpg will be the input:
|
||||||
|
|
||||||
curl -F profile=@portrait.jpg https://example.com/upload.cgi
|
curl -F profile=@portrait.jpg https://example.com/upload.cgi
|
||||||
|
|
||||||
To read content from stdin instead of a file, use - as the filename. This goes
|
Example: send a your name and shoe size in two text fields to the server:
|
||||||
for both @ and < constructs. If stdin is not attached to a regular file, it is
|
|
||||||
buffered first to determine its size and allow a possible resend. Defining a
|
curl -F name=John -F shoesize=11 https://example.com/
|
||||||
part's data from a named non-regular file (such as a named pipe or similar) is
|
|
||||||
unfortunately not subject to buffering and will be effectively read at
|
Example: send a your essay in a text field to the server. Send it as a plain
|
||||||
transmission time; since the full size is unknown before the transfer starts,
|
text field, but get the contents for it from a local file:
|
||||||
data is sent as chunks by HTTP and rejected by IMAP.
|
|
||||||
|
curl -F "story=<hugefile.txt" https://example.com/
|
||||||
|
|
||||||
You can also tell curl what Content-Type to use by using 'type=', in a manner
|
You can also tell curl what Content-Type to use by using 'type=', in a manner
|
||||||
similar to:
|
similar to:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user