1CURLOPT_UPLOAD(3)          curl_easy_setopt options          CURLOPT_UPLOAD(3)
2
3
4

NAME

6       CURLOPT_UPLOAD - data upload
7

SYNOPSIS

9       #include <curl/curl.h>
10
11       CURLcode curl_easy_setopt(CURL *handle, CURLOPT_UPLOAD, long upload);
12

DESCRIPTION

14       The long parameter upload set to 1 tells the library to prepare for and
15       perform an upload. The CURLOPT_READDATA(3) and CURLOPT_INFILESIZE(3) or
16       CURLOPT_INFILESIZE_LARGE(3)  options  are also interesting for uploads.
17       If the protocol is HTTP, uploading means using the PUT  request  unless
18       you tell libcurl otherwise.
19
20       Using  PUT  with  HTTP  1.1 implies the use of a "Expect: 100-continue"
21       header.  You can disable  this  header  with  CURLOPT_HTTPHEADER(3)  as
22       usual.
23
24       If you use PUT to an HTTP 1.1 server, you can upload data without know‐
25       ing the size before starting the transfer if you use chunked  encoding.
26       You  enable  this  by adding a header like "Transfer-Encoding: chunked"
27       with CURLOPT_HTTPHEADER(3). With HTTP 1.0 or without chunked  transfer,
28       you must specify the size.
29

DEFAULT

31       0, default is download
32

PROTOCOLS

34       Most
35

EXAMPLE

37       CURL *curl = curl_easy_init();
38       if(curl) {
39         /* we want to use our own read function */
40         curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_callback);
41
42         /* enable uploading */
43         curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
44
45         /* specify target */
46         curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com/dir/to/newfile");
47
48         /* now specify which pointer to pass to our callback */
49         curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
50
51         /* Set the size of the file to upload */
52         curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)fsize);
53
54         /* Now run off and do what you have been told! */
55         curl_easy_perform(curl);
56       }
57

AVAILABILITY

59       Always
60

RETURN VALUE

62       Returns CURLE_OK
63

SEE ALSO

65       CURLOPT_PUT(3), CURLOPT_READFUNCTION(3), CURLOPT_INFILESIZE_LARGE(3),
66
67
68
69libcurl 8.0.1                  January 02, 2023              CURLOPT_UPLOAD(3)
Impressum