CURLINFO_CONTENT_LENGTH_UPLOAD.md (1491B)
1 --- 2 c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 3 SPDX-License-Identifier: curl 4 Title: CURLINFO_CONTENT_LENGTH_UPLOAD 5 Section: 3 6 Source: libcurl 7 See-also: 8 - CURLINFO_CONTENT_LENGTH_DOWNLOAD_T (3) 9 - curl_easy_getinfo (3) 10 - curl_easy_setopt (3) 11 Protocol: 12 - All 13 Added-in: 7.6.1 14 --- 15 16 # NAME 17 18 CURLINFO_CONTENT_LENGTH_UPLOAD - get the specified size of the upload 19 20 # SYNOPSIS 21 22 ~~~c 23 #include <curl/curl.h> 24 25 CURLcode curl_easy_getinfo(CURL *handle, CURLINFO_CONTENT_LENGTH_UPLOAD, 26 double *content_length); 27 ~~~ 28 29 # DESCRIPTION 30 31 Pass a pointer to a double to receive the specified size of the upload. Since 32 7.19.4, this returns -1 if the size is not known. 33 34 CURLINFO_CONTENT_LENGTH_UPLOAD_T(3) is a newer replacement that returns a 35 more sensible variable type. 36 37 # %PROTOCOLS% 38 39 # EXAMPLE 40 41 ~~~c 42 int main(void) 43 { 44 CURL *curl = curl_easy_init(); 45 if(curl) { 46 CURLcode res; 47 curl_easy_setopt(curl, CURLOPT_URL, "https://example.com"); 48 49 /* Perform the upload */ 50 res = curl_easy_perform(curl); 51 52 if(!res) { 53 /* check the size */ 54 double cl; 55 res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_UPLOAD, &cl); 56 if(!res) { 57 printf("Size: %.0f\n", cl); 58 } 59 } 60 } 61 } 62 ~~~ 63 64 # DEPRECATED 65 66 Deprecated since 7.55.0. 67 68 # %AVAILABILITY% 69 70 # RETURN VALUE 71 72 curl_easy_getinfo(3) returns a CURLcode indicating success or error. 73 74 CURLE_OK (0) means everything was OK, non-zero means an error occurred, see 75 libcurl-errors(3).