Req #67477 [Com]: Multidimensional arrays and CURLFile in CURLOPT_POSTFIELDS
| From: | robertsonldspj596 at gmail dot com | Date: | Sat, 03 Dec 2022 06:43:18 +0000 |
| Subject: | Req #67477 [Com]: Multidimensional arrays and CURLFile in CURLOPT_POSTFIELDS | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-243040@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67477&edit=1
ID: 67477
Comment by: robertsonldspj596 at gmail dot com
Reported by: boris dot momcilovic at gmail dot com
Summary: Multidimensional arrays and CURLFile in
CURLOPT_POSTFIELDS
Status: Verified
Type: Feature/Change Request
Package: cURL related
Operating System: 3.14.6-1-ARCH x86_64
PHP Version: 5.5.13
Block user comment: N
Private report: N
New Comment:
A commitment of appreciation is all together for sharing, I found a tremendous store of stimulating
information here. A striking post, incredibly grateful and obliging that you will make on a very
major level more posts like this one.
(https://www.paymydoctor.ltd/)github.com
Previous Comments:
------------------------------------------------------------------------
[2014-06-19 12:38:21] boris dot momcilovic at gmail dot com
Description:
------------
Trying to set multidimensional array as CURLOPT_POSTFIELDS issues a NOTICE, and I suppose that end
user should make a string out (that way it's allright).
However, I see no way to pass a multidimensional array and a file together using CURLFile - which is
encouraged as of 5.5.0 (and since '@' notation is deprecated).
Test script:
---------------
<?php
$data =
[
'checked' => ['a', 'b', 'c'],
];
$ch = curl_init();
curl_setopt ($ch, CURLOPT_POSTFIELDS, http_build_query ($data));
// works fine
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
// Notice: Array to string conversion in test.php on line 12
$data =
[
'checked' => ['a', 'b', 'c'],
'file' => new CURLFile ('test.php')
];
curl_setopt ($ch, CURLOPT_POSTFIELDS, $data);
// Notice: Array to string conversion in test.php on line 20
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67477&edit=1