xref: /aosp_15_r20/external/curl/docs/cmdline-opts/upload-file.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerLong: upload-file
5*6236dae4SAndroid Build Coastguard WorkerShort: T
6*6236dae4SAndroid Build Coastguard WorkerArg: <file>
7*6236dae4SAndroid Build Coastguard WorkerHelp: Transfer local FILE to destination
8*6236dae4SAndroid Build Coastguard WorkerCategory: important upload
9*6236dae4SAndroid Build Coastguard WorkerAdded: 4.0
10*6236dae4SAndroid Build Coastguard WorkerMulti: per-URL
11*6236dae4SAndroid Build Coastguard WorkerSee-also:
12*6236dae4SAndroid Build Coastguard Worker  - get
13*6236dae4SAndroid Build Coastguard Worker  - head
14*6236dae4SAndroid Build Coastguard Worker  - request
15*6236dae4SAndroid Build Coastguard Worker  - data
16*6236dae4SAndroid Build Coastguard WorkerExample:
17*6236dae4SAndroid Build Coastguard Worker  - -T file $URL
18*6236dae4SAndroid Build Coastguard Worker  - -T "img[1-1000].png" ftp://ftp.example.com/
19*6236dae4SAndroid Build Coastguard Worker  - --upload-file "{file1,file2}" $URL
20*6236dae4SAndroid Build Coastguard Worker  - -T file -T file2 $URL $URL
21*6236dae4SAndroid Build Coastguard Worker---
22*6236dae4SAndroid Build Coastguard Worker
23*6236dae4SAndroid Build Coastguard Worker# `--upload-file`
24*6236dae4SAndroid Build Coastguard Worker
25*6236dae4SAndroid Build Coastguard WorkerUpload the specified local file to the remote URL.
26*6236dae4SAndroid Build Coastguard Worker
27*6236dae4SAndroid Build Coastguard WorkerIf there is no file part in the specified URL, curl appends the local file
28*6236dae4SAndroid Build Coastguard Workername to the end of the URL before the operation starts. You must use a
29*6236dae4SAndroid Build Coastguard Workertrailing slash (/) on the last directory to prove to curl that there is no
30*6236dae4SAndroid Build Coastguard Workerfilename or curl thinks that your last directory name is the remote filename
31*6236dae4SAndroid Build Coastguard Workerto use.
32*6236dae4SAndroid Build Coastguard Worker
33*6236dae4SAndroid Build Coastguard WorkerWhen putting the local filename at the end of the URL, curl ignores what is on
34*6236dae4SAndroid Build Coastguard Workerthe left side of any slash (/) or backslash (\) used in the filename and only
35*6236dae4SAndroid Build Coastguard Workerappends what is on the right side of the rightmost such character.
36*6236dae4SAndroid Build Coastguard Worker
37*6236dae4SAndroid Build Coastguard WorkerUse the filename `-` (a single dash) to use stdin instead of a given file.
38*6236dae4SAndroid Build Coastguard WorkerAlternately, the filename `.` (a single period) may be specified instead of
39*6236dae4SAndroid Build Coastguard Worker`-` to use stdin in non-blocking mode to allow reading server output while
40*6236dae4SAndroid Build Coastguard Workerstdin is being uploaded.
41*6236dae4SAndroid Build Coastguard Worker
42*6236dae4SAndroid Build Coastguard WorkerIf this option is used with an HTTP(S) URL, the PUT method is used.
43*6236dae4SAndroid Build Coastguard Worker
44*6236dae4SAndroid Build Coastguard WorkerYou can specify one --upload-file for each URL on the command line. Each
45*6236dae4SAndroid Build Coastguard Worker--upload-file + URL pair specifies what to upload and to where. curl also
46*6236dae4SAndroid Build Coastguard Workersupports globbing of the --upload-file argument, meaning that you can upload
47*6236dae4SAndroid Build Coastguard Workermultiple files to a single URL by using the same URL globbing style supported
48*6236dae4SAndroid Build Coastguard Workerin the URL.
49*6236dae4SAndroid Build Coastguard Worker
50*6236dae4SAndroid Build Coastguard WorkerWhen uploading to an SMTP server: the uploaded data is assumed to be RFC 5322
51*6236dae4SAndroid Build Coastguard Workerformatted. It has to feature the necessary set of headers and mail body
52*6236dae4SAndroid Build Coastguard Workerformatted correctly by the user as curl does not transcode nor encode it
53*6236dae4SAndroid Build Coastguard Workerfurther in any way.
54