|  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
Avg. Score:4.3 ± 1.1
Reproduced:32 of 32 (100.0%)
Same Version:13 (40.6%)
Same OS:5 (15.6%)
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:
Solve the problem:
21 + 4 = ?
Subscribe to this entry?

 [2014-06-19 12:38 UTC] boris dot momcilovic at gmail dot com
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:

$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


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


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-26 16:48 UTC]
-Status: Open +Status: Verified -Type: Bug +Type: Feature/Change Request
 [2022-12-03 06:43 UTC] robertsonldspj596 at gmail dot com
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.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 10:01:29 2024 UTC