1--- 2c: Copyright (C) Daniel Stenberg, <daniel.se>, et al. 3SPDX-License-Identifier: curl 4Title: curl_mime_filename 5Section: 3 6Source: libcurl 7See-also: 8 - curl_mime_addpart (3) 9 - curl_mime_data (3) 10 - curl_mime_filedata (3) 11--- 12 13# NAME 14 15curl_mime_filename - set a mime part's remote file name 16 17# SYNOPSIS 18 19~~~c 20#include <curl/curl.h> 21 22CURLcode curl_mime_filename(curl_mimepart *part, 23 const char *filename); 24~~~ 25 26# DESCRIPTION 27 28curl_mime_filename(3) sets a mime part's remote filename. When remote 29filename is set, content data is processed as a file, whatever is the part's 30content source. A part's remote filename is transmitted to the server in the 31associated Content-Disposition generated header. 32 33*part* is the part's handle to assign the remote filename to. 34 35*filename* points to the null-terminated filename string; it may be set 36to NULL to remove a previously attached remote filename. 37 38The remote filename string is copied into the part, thus the associated 39storage may safely be released or reused after call. Setting a part's file 40name multiple times is valid: only the value set by the last call is retained. 41 42# EXAMPLE 43 44~~~c 45 46static char imagebuf[]="imagedata"; 47 48int main(void) 49{ 50 curl_mime *mime; 51 curl_mimepart *part; 52 53 CURL *curl = curl_easy_init(); 54 if(curl) { 55 /* create a mime handle */ 56 mime = curl_mime_init(curl); 57 58 /* add a part */ 59 part = curl_mime_addpart(mime); 60 61 /* send image data from memory */ 62 curl_mime_data(part, imagebuf, sizeof(imagebuf)); 63 64 /* set a file name to make it look like a file upload */ 65 curl_mime_filename(part, "image.png"); 66 67 /* set name */ 68 curl_mime_name(part, "data"); 69 } 70} 71~~~ 72 73# AVAILABILITY 74 75As long as at least one of HTTP, SMTP or IMAP is enabled. Added in 7.56.0. 76 77# RETURN VALUE 78 79CURLE_OK or a CURL error code upon failure. 80