php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47906 CURLOPT_POSTFIELDS accepts only strings
Submitted: 2009-04-06 11:48 UTC Modified: 2010-03-07 19:36 UTC
Votes:5
Avg. Score:3.2 ± 1.2
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: klas at k-k-k dot biz Assigned:
Status: No Feedback Package: cURL related
PHP Version: 5.2.8 OS: windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: klas at k-k-k dot biz
New email:
PHP Version: OS:

 

 [2009-04-06 11:48 UTC] klas at k-k-k dot biz
Description:
------------
Inserting array (key=>value) as CURLOPT_POSTFIELDS doesn't work although documentation states:

 "This can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value. "

Reproduce code:
---------------
$url="example.php";
$process = curl_init($url);
$data= array ('somefield'=>'somedata')
curl_setopt($process, CURLOPT_POSTFIELDS, $data);
curl_exec($process);
curl_close($process);

Expected result:
----------------
input field "somefield" with value "somedata" posted to example.php

Actual result:
--------------
Empty field/value

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-06 12:46 UTC] jani@php.net
You just need to disable the Expect header cURL sends by default:

http://the-stickman.com/web-development/php-and-curl-disabling-100-continue-header/

 [2009-04-06 13:11 UTC] klas at k-k-k dot biz
Sorry, but that doesn't work. 

Note that this is a different problem that the one described on that page.
 [2009-04-06 14:15 UTC] iliaa@php.net
Works fine for me with both 5.2 and 5.3. What version of libcurl are you 
using?
 [2009-04-06 14:35 UTC] klas at k-k-k dot biz
I'm using xampp that currently comes with php 5.2.8. and libcurl 7.16.0
 [2009-04-06 14:42 UTC] pajoye@php.net
Please try a 5.3 VC9 snapshot (using cli, IIS with NTS, or apachelounge.com's apache for the ts version).

You can fetch at http://windows.php.net
 [2009-04-06 14:44 UTC] pajoye@php.net
sorry, 5.2.9-1 will do it as well :)
 [2009-04-14 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-03-07 19:36 UTC] felipe@php.net
-Package: Scripting Engine problem +Package: cURL related
 [2013-01-21 03:51 UTC] ldxing999 at gmail dot com
Just use http_build_query() to parse array to encode str, that's OK
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC