diff --git a/user_guide_src/source/libraries/curlrequest.rst b/user_guide_src/source/libraries/curlrequest.rst index b33fad802f4a..1e06b69cc484 100644 --- a/user_guide_src/source/libraries/curlrequest.rst +++ b/user_guide_src/source/libraries/curlrequest.rst @@ -260,7 +260,7 @@ if it's not already set: .. literalinclude:: curlrequest/024.php -.. note:: ``form_params`` cannot be used with the ``multipart`` option. You will need to use one or the other. +.. note:: ``form_params`` cannot be used with the `multipart`_ option. You will need to use one or the other. Use ``form_params`` for ``application/x-www-form-urlencoded`` request, and ``multipart`` for ``multipart/form-data`` requests. @@ -306,13 +306,15 @@ multipart ========= When you need to send files and other data via a POST request, you can use the ``multipart`` option, along with -the `CURLFile Class `_. The values should be an associative array -of POST data to send. For safer usage, the legacy method of uploading files by prefixing their name with an `@` +the `CURLFile Class `_. + +The values should be an associative array +of POST data to send. For safer usage, the legacy method of uploading files by prefixing their name with an ``@`` has been disabled. Any files that you want to send must be passed as instances of CURLFile: .. literalinclude:: curlrequest/028.php -.. note:: ``multipart`` cannot be used with the ``form_params`` option. You can only use one or the other. Use +.. note:: ``multipart`` cannot be used with the `form_params`_ option. You can only use one or the other. Use ``form_params`` for ``application/x-www-form-urlencoded`` requests, and ``multipart`` for ``multipart/form-data`` requests. diff --git a/user_guide_src/source/libraries/curlrequest/028.php b/user_guide_src/source/libraries/curlrequest/028.php index fcce227c1d9a..e56b96b127a5 100644 --- a/user_guide_src/source/libraries/curlrequest/028.php +++ b/user_guide_src/source/libraries/curlrequest/028.php @@ -1,6 +1,8 @@ 'bar', - 'userfile' => new \CURLFile('/path/to/file.txt'), -]; +$client->request('POST', '/post', [ + 'multipart' => [ + 'foo' => 'bar', + 'userfile' => new \CURLFile('/path/to/file.txt'), + ], +]);