使用PHP cURL发送数据时缺少结束边界

I have some content like this :

Content-Disposition: form-data; name="metadata"

{{ METADATA JSON}}


Content-Disposition: form-data; name="audio"

{{ AUDIO DATA}}`

I am trying to send this data as multipart/form-data

To do this I am doing the following :

$postData = array('metadata'=>$metaData,'audio'=>$audio);
curl_setopt($ch,CURLOPT_POSTFIELDS,$postData);
  • PHP-cURL is able to create proper request with proper headers and boundary

But the issue is WHEN AUDIO DATA IS BIG it misses to add end boundary term in the request, if audio data is small it adds end boundary term without any issue but with big data, it misses to add the end boundary term.

Sample request body looks like this when {{ BINARY AUDIO DATA }} is small:

--------------------------d220a6d2f1348ca3

Content-Disposition: form-data; name="metadata"

{{ METADATA JSON }}


--------------------------d220a6d2f1348ca3

Content-Disposition: form-data; name="audio"

{{ BINARY AUDIO DATA }}

--------------------------d220a6d2f1348ca3--

Sample request body looks like this when {{ BINARY AUDIO DATA }} is big:

--------------------------d220a6d2f1348ca3

Content-Disposition: form-data; name="metadata"

{{ METADATA JSON }}


--------------------------d220a6d2f1348ca3

Content-Disposition: form-data; name="audio"

{{ BINARY AUDIO DATA }}
//-----------------------  <----  Missing this boundary