mirror of
https://github.com/curl/curl.git
synced 2026-06-04 04:04:15 +03:00
Use parts of text from the upload filename field when that uses globbing
by giving it a name the same way we do it for URL globs. For example, if
you upload three files to a HTTP URL and want to save the corresponding
responses in separate files:
curl -T 'file{<num>1,2,3}' https://upload.example/ -o 'response-#<num>'
Verified by test 2014
Closes #21407
63 lines
2.3 KiB
Markdown
63 lines
2.3 KiB
Markdown
---
|
|
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
SPDX-License-Identifier: curl
|
|
Long: upload-file
|
|
Short: T
|
|
Arg: <file>
|
|
Help: Transfer local FILE to destination
|
|
Category: important upload
|
|
Added: 4.0
|
|
Multi: per-URL
|
|
See-also:
|
|
- get
|
|
- head
|
|
- request
|
|
- data
|
|
Example:
|
|
- -T file $URL
|
|
- -T "img[1-1000].png" ftp://ftp.example.com/
|
|
- --upload-file "{file1,file2}" $URL
|
|
- -T file -T file2 $URL $URL
|
|
---
|
|
|
|
# `--upload-file`
|
|
|
|
Upload the specified local file to the remote URL.
|
|
|
|
If there is no file part in the specified URL, curl appends the local file
|
|
name to the end of the URL before the operation starts. You must use a
|
|
trailing slash (`/`) on the last directory to prove to curl that there is no
|
|
filename or curl thinks that your last directory name is the remote filename
|
|
to use.
|
|
|
|
When putting the local filename at the end of the URL, curl ignores what is on
|
|
the left side of any slash (`/`) or backslash (`\\`) used in the filename and
|
|
only appends what is on the right side of the rightmost such character.
|
|
|
|
Use the filename `-` (a single dash) to use stdin instead of a given file.
|
|
Alternately, the filename `.` (a single period) may be specified instead of
|
|
`-` to use stdin in non-blocking mode to allow reading server output while
|
|
stdin is being uploaded.
|
|
|
|
If this option is used with an HTTP(S) URL, the PUT method is used.
|
|
|
|
You can specify one --upload-file for each URL on the command line. Each
|
|
--upload-file + URL pair specifies what to upload and to where. curl also
|
|
supports globbing of the --upload-file argument, meaning that you can upload
|
|
multiple files to a single URL by using the same URL globbing style supported
|
|
in the URL. Example:
|
|
|
|
curl --upload-file 'file{1,2,3}' ftp://ftp.example/
|
|
|
|
Since curl 8.21.0, you can use parts of the upload filename when it uses
|
|
globbing by setting a glob name and referencing that in the same way you
|
|
reference named URL globs. For example, if you upload three files to a single
|
|
fixed HTTP URL and want to save the corresponding responses in separate files:
|
|
|
|
curl -T 'file{<num>1,2,3}' \
|
|
https://upload.example/ -o 'response-#<num>'
|
|
|
|
When uploading to an SMTP server (aka "sending email"): the uploaded data is
|
|
assumed to be RFC 5322 formatted. It has to feature the necessary set of
|
|
headers and mail body formatted correctly by the user as curl does not
|
|
transcode nor encode it further in any way.
|