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:36
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 Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
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)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-03-26 16:48 UTC] mike@php.net
-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.
(https://www.paymydoctor.ltd/)github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Nov 06 09:01:30 2024 UTC