CURLOPT_MIMEPOST.3 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 "22 Aug 2017" libcurl libcurl
  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. When setting \fICURLOPT_MIMEPOST(3)\fP to NULL, libcurl resets the request
  40. type for HTTP to the default to disable the POST. Typically that would mean it
  41. is reset to GET. Instead you should set a desired request method explicitly.
  42. .SH PROTOCOLS
  43. HTTP, SMTP, IMAP.
  44. .SH EXAMPLE
  45. .nf
  46. curl_mime *multipart = curl_mime_init(handle);
  47. curl_mimepart *part = curl_mime_addpart(multipart);
  48. curl_mime_name(part, "name");
  49. curl_mime_data(part, "daniel", CURL_ZERO_TERMINATED);
  50. part = curl_mime_addpart(multipart);
  51. curl_mime_name(part, "project");
  52. curl_mime_data(part, "curl", CURL_ZERO_TERMINATED);
  53. part = curl_mime_addpart(multipart);
  54. curl_mime_name(part, "logotype-image");
  55. curl_mime_filedata(part, "curl.png");
  56. /* Set the form info */
  57. curl_easy_setopt(handle, CURLOPT_MIMEPOST, multipart);
  58. curl_easy_perform(handle); /* post away! */
  59. curl_mime_free(multipart); /* free the post data */
  60. .fi
  61. .SH AVAILABILITY
  62. Added in 7.56.0
  63. .SH RETURN VALUE
  64. This will return CURLE_OK.
  65. .SH "SEE ALSO"
  66. .BR curl_mime_init "(3)"