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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
9 + 37 = ?
Subscribe to this entry?

 
 [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: Fri Dec 13 05:01:26 2019 UTC