php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #48083 curl_setopt page incorrectly describes CURLOPT_POST behavior
Submitted: 2009-04-27 08:38 UTC Modified: 2009-04-27 11:41 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mrtorrent at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mrtorrent at gmail dot com
New email:
PHP Version: OS:

 

 [2009-04-27 08:38 UTC] mrtorrent at gmail dot com
Description:
------------
As per #37760 and #16305, the curl_setopt manual page makes no mention of the fact that passing an array to CURLOPT_POSTFIELDS results in a post of type multipart/form-data rather than application/x-www-form-urlencoded when passing an array to CUROPT_POSTFIELDS instead of a string.

37760 was closed a year and half ago as fixed, but it does not actually appear to be, and this behavior is documented only in user comments on the manual apge.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-27 11:41 UTC] dave@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

I\'ve updated the documentation to reflect this.

The Content-Type is forced to multipart/form-data if an array is passed to CURLOPT_POSTFIELDS. This is due to the extension using CURLOPT_HTTPPOST (which allows the use of files) for array parameters instead of CURLOPT_POSTFIELDS or CURLOPT_COPYPOSTFIELDS.

CURLOPT_HTTPPOST only really needs to be used if you\'re using file uploads, so it\'s possible the code could be changed to detect this, however it\'s probably easier to just pass a string to CURLOPT_POSTFIELDS if you\'re not doing file uploads. ie. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($array));
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Jul 04 11:01:37 2025 UTC