Posting multidimensional array with PHP and CURL

前端 未结 8 2051
难免孤独
难免孤独 2020-11-27 06:29

I\'m having trouble posting form data via CURL to a receiving PHP script located on a different host.

I get an Array to string conversion error

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-27 06:30

    You'd have to build the POST string manually, rather than passing the entire array in. You can then override curl's auto-chose content header with:

    curl_setopt($c, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data"));
    

    Serializing/json-ifying would be easier, but as you say, you have no control over the receiving end, so you've got a bit of extra work to do.

提交回复
热议问题