|  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
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
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:
45 - 7 = ?
Subscribe to this entry?

 [2009-04-06 11:48 UTC] klas at k-k-k dot biz
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:
$process = curl_init($url);
$data= array ('somefield'=>'somedata')
curl_setopt($process, CURLOPT_POSTFIELDS, $data);

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

Actual result:
Empty field/value


Add a Patch

Pull Requests

Add a Pull Request


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

 [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]
Works fine for me with both 5.2 and 5.3. What version of libcurl are you 
 [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]
Please try a 5.3 VC9 snapshot (using cli, IIS with NTS, or's apache for the ts version).

You can fetch at
 [2009-04-06 14:44 UTC]
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]
-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-2023 The PHP Group
All rights reserved.
Last updated: Tue Dec 05 05:01:29 2023 UTC