php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67477 Multidimensional arrays and CURLFile in CURLOPT_POSTFIELDS
Submitted: 2014-06-19 12:38 UTC Modified: 2019-03-26 16:48 UTC
Votes:32
Avg. Score:4.2 ± 1.1
Reproduced:28 of 28 (100.0%)
Same Version:11 (39.3%)
Same OS:3 (10.7%)
From: boris dot momcilovic at gmail dot com Assigned:
Status: Verified Package: cURL related
PHP Version: 5.5.13 OS: 3.14.6-1-ARCH x86_64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: boris dot momcilovic at gmail dot com
New email:
PHP Version: OS:

 

 [2014-06-19 12:38 UTC] 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


Patches

add-http_build_query_develop-function (last revision 2015-12-29 14:13 UTC by hzgdys at 163 dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-26 16:48 UTC] mike@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Feature/Change Request
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 16:01:21 2019 UTC