CURLOPT_MIMEPOST.3 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. .\" **************************************************************************
  2. .\" * _ _ ____ _
  3. .\" * Project ___| | | | _ \| |
  4. .\" * / __| | | | |_) | |
  5. .\" * | (__| |_| | _ <| |___
  6. .\" * \___|\___/|_| \_\_____|
  7. .\" *
  8. .\" * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  9. .\" *
  10. .\" * This software is licensed as described in the file COPYING, which
  11. .\" * you should have received as part of this distribution. The terms
  12. .\" * are also available at https://curl.se/docs/copyright.html.
  13. .\" *
  14. .\" * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. .\" * copies of the Software, and permit persons to whom the Software is
  16. .\" * furnished to do so, under the terms of the COPYING file.
  17. .\" *
  18. .\" * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. .\" * KIND, either express or implied.
  20. .\" *
  21. .\" * SPDX-License-Identifier: curl
  22. .\" *
  23. .\" **************************************************************************
  24. .\"
  25. .TH CURLOPT_MIMEPOST 3 "January 02, 2023" "libcurl 7.88.1" "curl_easy_setopt options"
  26. .SH NAME
  27. CURLOPT_MIMEPOST \- send data from mime structure
  28. .SH SYNOPSIS
  29. .nf
  30. #include <curl/curl.h>
  31. curl_mime *mime;
  32. CURLcode curl_easy_setopt(CURL *handle, CURLOPT_MIMEPOST, mime);
  33. .SH DESCRIPTION
  34. Pass a mime handle previously obtained from \fIcurl_mime_init(3)\fP.
  35. This setting is supported by the HTTP protocol to post forms and by the
  36. SMTP and IMAP protocols to provide the email data to send/upload.
  37. This option is the preferred way of posting an HTTP form, replacing and
  38. extending the \fICURLOPT_HTTPPOST(3)\fP option.
  39. .SH PROTOCOLS
  40. HTTP, SMTP, IMAP.
  41. .SH EXAMPLE
  42. .nf
  43. curl_mime *multipart = curl_mime_init(handle);
  44. curl_mimepart *part = curl_mime_addpart(multipart);
  45. curl_mime_name(part, "name");
  46. curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED);
  47. part = curl_mime_addpart(multipart);
  48. curl_mime_name(part, "project");
  49. curl_mime_data(part, "curl", CURL_ZERO_TERMINATED);
  50. part = curl_mime_addpart(multipart);
  51. curl_mime_name(part, "logotype-image");
  52. curl_mime_filedata(part, "curl.png");
  53. /* Set the form info */
  54. curl_easy_setopt(handle, CURLOPT_MIMEPOST, multipart);
  55. curl_easy_perform(handle); /* post away! */
  56. curl_mime_free(multipart); /* free the post data */
  57. .fi
  58. .SH AVAILABILITY
  59. Added in 7.56.0
  60. .SH RETURN VALUE
  61. This will return CURLE_OK.
  62. .SH "SEE ALSO"
  63. .BR curl_mime_init "(3)"