Skip to content

Commit fe3f489

Browse files
authored
Merge pull request #9093 from kenjis/docs-curlrequest.rst
docs: improve CURLRequest sample code
2 parents 82dbd91 + a2dffb3 commit fe3f489

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

user_guide_src/source/libraries/curlrequest.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ if it's not already set:
260260

261261
.. literalinclude:: curlrequest/024.php
262262

263-
.. note:: ``form_params`` cannot be used with the ``multipart`` option. You will need to use one or the other.
263+
.. note:: ``form_params`` cannot be used with the `multipart`_ option. You will need to use one or the other.
264264
Use ``form_params`` for ``application/x-www-form-urlencoded`` request, and ``multipart`` for ``multipart/form-data``
265265
requests.
266266

@@ -306,13 +306,15 @@ multipart
306306
=========
307307

308308
When you need to send files and other data via a POST request, you can use the ``multipart`` option, along with
309-
the `CURLFile Class <https://www.php.net/manual/en/class.curlfile.php>`_. The values should be an associative array
310-
of POST data to send. For safer usage, the legacy method of uploading files by prefixing their name with an `@`
309+
the `CURLFile Class <https://www.php.net/manual/en/class.curlfile.php>`_.
310+
311+
The values should be an associative array
312+
of POST data to send. For safer usage, the legacy method of uploading files by prefixing their name with an ``@``
311313
has been disabled. Any files that you want to send must be passed as instances of CURLFile:
312314

313315
.. literalinclude:: curlrequest/028.php
314316

315-
.. note:: ``multipart`` cannot be used with the ``form_params`` option. You can only use one or the other. Use
317+
.. note:: ``multipart`` cannot be used with the `form_params`_ option. You can only use one or the other. Use
316318
``form_params`` for ``application/x-www-form-urlencoded`` requests, and ``multipart`` for ``multipart/form-data``
317319
requests.
318320

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
$post_data = [
4-
'foo' => 'bar',
5-
'userfile' => new \CURLFile('/path/to/file.txt'),
6-
];
3+
$client->request('POST', '/post', [
4+
'multipart' => [
5+
'foo' => 'bar',
6+
'userfile' => new \CURLFile('/path/to/file.txt'),
7+
],
8+
]);

0 commit comments

Comments
 (0)