xref: /curl/docs/cmdline-opts/upload-file.md (revision 2d3a51e3)
1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Long: upload-file
5Short: T
6Arg: <file>
7Help: Transfer local FILE to destination
8Category: important upload
9Added: 4.0
10Multi: per-URL
11See-also:
12  - get
13  - head
14  - request
15  - data
16Example:
17  - -T file $URL
18  - -T "img[1-1000].png" ftp://ftp.example.com/
19  - --upload-file "{file1,file2}" $URL
20  - -T file -T file2 $URL $URL
21---
22
23# `--upload-file`
24
25Upload the specified local file to the remote URL.
26
27If there is no file part in the specified URL, curl appends the local file
28name to the end of the URL before the operation starts. You must use a
29trailing slash (/) on the last directory to prove to curl that there is no
30filename or curl thinks that your last directory name is the remote filename
31to use.
32
33When putting the local filename at the end of the URL, curl ignores what is on
34the left side of any slash (/) or backslash (\) used in the filename and only
35appends what is on the right side of the rightmost such character.
36
37Use the filename `-` (a single dash) to use stdin instead of a given file.
38Alternately, the filename `.` (a single period) may be specified instead of
39`-` to use stdin in non-blocking mode to allow reading server output while
40stdin is being uploaded.
41
42If this option is used with an HTTP(S) URL, the PUT method is used.
43
44You can specify one --upload-file for each URL on the command line. Each
45--upload-file + URL pair specifies what to upload and to where. curl also
46supports globbing of the --upload-file argument, meaning that you can upload
47multiple files to a single URL by using the same URL globbing style supported
48in the URL.
49
50When uploading to an SMTP server: the uploaded data is assumed to be RFC 5322
51formatted. It has to feature the necessary set of headers and mail body
52formatted correctly by the user as curl does not transcode nor encode it
53further in any way.
54