curl_mime_filename.3 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. .\" generated by cd2nroff 0.1 from curl_mime_filename.md
  2. .TH curl_mime_filename 3 "2025-01-17" libcurl
  3. .SH NAME
  4. curl_mime_filename \- set a mime part\(aqs remote filename
  5. .SH SYNOPSIS
  6. .nf
  7. #include <curl/curl.h>
  8. CURLcode curl_mime_filename(curl_mimepart *part,
  9. const char *filename);
  10. .fi
  11. .SH DESCRIPTION
  12. \fIcurl_mime_filename(3)\fP sets a mime part\(aqs remote filename. When remote
  13. filename is set, content data is processed as a file, whatever is the part\(aqs
  14. content source. A part\(aqs remote filename is transmitted to the server in the
  15. associated Content\-Disposition generated header.
  16. \fIpart\fP is the part\(aqs handle to assign the remote filename to.
  17. \fIfilename\fP points to the null\-terminated filename string; it may be set
  18. to NULL to remove a previously attached remote filename.
  19. The remote filename string is copied into the part, thus the associated
  20. storage may safely be released or reused after call. Setting a part\(aqs file
  21. name multiple times is valid: only the value set by the last call is retained.
  22. .SH PROTOCOLS
  23. This functionality affects http, imap and smtp
  24. .SH EXAMPLE
  25. .nf
  26. static char imagebuf[]="imagedata";
  27. int main(void)
  28. {
  29. curl_mime *mime;
  30. curl_mimepart *part;
  31. CURL *curl = curl_easy_init();
  32. if(curl) {
  33. /* create a mime handle */
  34. mime = curl_mime_init(curl);
  35. /* add a part */
  36. part = curl_mime_addpart(mime);
  37. /* send image data from memory */
  38. curl_mime_data(part, imagebuf, sizeof(imagebuf));
  39. /* set a file name to make it look like a file upload */
  40. curl_mime_filename(part, "image.png");
  41. /* set name */
  42. curl_mime_name(part, "data");
  43. }
  44. }
  45. .fi
  46. .SH AVAILABILITY
  47. Added in curl 7.56.0
  48. .SH RETURN VALUE
  49. CURLE_OK or a CURL error code upon failure.
  50. .SH SEE ALSO
  51. .BR curl_mime_addpart (3),
  52. .BR curl_mime_data (3),
  53. .BR curl_mime_filedata (3)