1---
2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_INFILESIZE
5Section: 3
6Source: libcurl
7See-also:
8  - CURLINFO_CONTENT_LENGTH_UPLOAD_T (3)
9  - CURLOPT_INFILESIZE_LARGE (3)
10  - CURLOPT_UPLOAD (3)
11---
12
13# NAME
14
15CURLOPT_INFILESIZE - size of the input file to send off
16
17# SYNOPSIS
18
19~~~c
20#include <curl/curl.h>
21
22CURLcode curl_easy_setopt(CURL *handle, CURLOPT_INFILESIZE, long filesize);
23~~~
24
25# DESCRIPTION
26
27When uploading a file to a remote site, *filesize* should be used to tell
28libcurl what the expected size of the input file is. This value must be passed
29as a long. See also CURLOPT_INFILESIZE_LARGE(3) for sending files larger
30than 2GB.
31
32For uploading using SCP, this option or CURLOPT_INFILESIZE_LARGE(3) is
33mandatory.
34
35To unset this value again, set it to -1.
36
37Using CURLOPT_UPLOAD(3) to an HTTP/1.1 server and this value set to -1, makes
38libcurl do a chunked transfer-encoded upload.
39
40When sending emails using SMTP, this command can be used to specify the
41optional SIZE parameter for the MAIL FROM command.
42
43This option does not limit how much data libcurl actually sends, as that is
44controlled entirely by what the read callback returns, but telling one value
45and sending a different amount may lead to errors.
46
47# DEFAULT
48
49Unset
50
51# PROTOCOLS
52
53Many
54
55# EXAMPLE
56
57~~~c
58
59#define FILE_SIZE 12345L
60
61int main(void)
62{
63  CURL *curl = curl_easy_init();
64  if(curl) {
65    long uploadsize = FILE_SIZE;
66
67    curl_easy_setopt(curl, CURLOPT_URL,
68                     "ftp://example.com/destination.tar.gz");
69
70    curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
71
72    curl_easy_setopt(curl, CURLOPT_INFILESIZE, uploadsize);
73
74    curl_easy_perform(curl);
75  }
76}
77~~~
78
79# AVAILABILITY
80
81SMTP support added in 7.23.0
82
83# RETURN VALUE
84
85Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not.
86