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