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