Closed
Description
Description
This is related to #33488 but with form data instead of a query string. Basically I need to POST
multiple values for the same filed. The FormDataPart
automatically appends [key]
to the filed's name, which in my case does not work as the api I'm using doesn't support this format. It would be great if there was a way to control this behavior and prevent the key from being appended to the name.
Example
$formFields = [
'text' => [
new TextPart('text1'),
new TextPart('text2'),
],
];
$formData = new FormDataPart($formFields);
var_dump($formData->toString());
Actual:
Content-Type: multipart/form-data; boundary=YtAhd-DW\r\n\r\n--YtAhd-DW\r\n
Content-Type: application/octet-stream\r\nContent-Transfer-Encoding: 8bit\r\n
Content-Disposition: form-data; name="text[0]"\r\n\r\n/text1\r\n--YtAhd-DW\r\n
Content-Type: application/octet-stream\r\nContent-Transfer-Encoding: 8bit\r\n
Content-Disposition: form-data; name="text[1]"\r\n\r\n/text2\r\n--YtAhd-DW--\r\n
Expected:
Content-Type: multipart/form-data; boundary=YtAhd-DW\r\n\r\n--YtAhd-DW\r\n
Content-Type: application/octet-stream\r\nContent-Transfer-Encoding: 8bit\r\n
Content-Disposition: form-data; name="text"\r\n\r\n/text1\r\n--YtAhd-DW\r\n
Content-Type: application/octet-stream\r\nContent-Transfer-Encoding: 8bit\r\n
Content-Disposition: form-data; name="text"\r\n\r\n/text2\r\n--YtAhd-DW--\r\n