Bug #67477 [NEW]: Multidimensional arrays and CURLFile in CURLOPT_POSTFIELDS

From: Date: Thu, 19 Jun 2014 12:38:21 +0000
Subject: Bug #67477 [NEW]: Multidimensional arrays and CURLFile in CURLOPT_POSTFIELDS
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186255@lists.php.net to get a copy of this message
From:             boris dot momcilovic at gmail dot com
Operating system: 3.14.6-1-ARCH x86_64
PHP version:      5.5.13
Package:          cURL related
Bug Type:         Bug
Bug description:Multidimensional arrays and CURLFile in CURLOPT_POSTFIELDS

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 bug report at https://bugs.php.net/bug.php?id=67477&edit=1
-- 



Thread (3 messages)

« previous php.bugs (#186255) next »