|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2018-04-13 08:19 UTC] requinix@php.net
-Summary: Post not working with subarray and file
+Summary: CURLOPT_POSTFIELDS should support key[] syntax for
array values
-Type: Bug
+Type: Feature/Change Request
[2018-04-13 08:19 UTC] requinix@php.net
[2018-04-13 08:20 UTC] requinix@php.net
-Summary: CURLOPT_POSTFIELDS should support key[] syntax for
array values
+Summary: Post not working with subarray and file
-Status: Open
+Status: Duplicate
-Type: Feature/Change Request
+Type: Bug
[2018-04-13 08:20 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 10:00:01 2025 UTC |
Description: ------------ do you have any idea, how to post file with subarray form fields Simple example: I need to have in form multiple var[] variables. So I build post array: $curlfile = curl_file_create($filename); $postdata = array('file'=> $curlfile, 'var' => array('value1', 'value2') ); curl_setopt($ch,CURLOPT_POSTFIELDS, $postdata); Then I will make simple post request, but it is not working. When I inspect the result with https://httpbin.org/post or print_r($_POST) variable on my site, it will show only Array ( [var] => Array ) I need to have in post request var[]=value1&var[]=value2 Test script: --------------- $curlfile = curl_file_create($filename); $postdata = array('file'=> $curlfile, 'var' => array('value1', 'value2') ); $ch = curl_init ("https://httpbin.org/post"); curl_setopt($ch,CURLOPT_POST, true); curl_setopt($ch,CURLOPT_POSTFIELDS, $postdata); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $output = curl_exec($ch); Expected result: ---------------- "form": { "var[]": [ "value1", "value2" ] }, Actual result: -------------- "form": { "var": "Array", },