Hi everyone, 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
This is print_r
of the array I'm posting:
Array
(
[name] => Array
(
[0] => Jason
[1] => Mary
[2] => Lucy
)
[id] => 12
[status] => local
[file] => @/test.txt
)
This is the line the error occurs on:
curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post);
The third argument must be an array because I need the Content-Type
header to be set to multipart/form-data
as I am sending a file via this same array, therefore I cannot convert the array to a query string or use http_build_query()
.
Also I do not have access to the code on the receiving host so I cannot serialize and unserialize the array.
I'm assuming that the value of the name key being an array is the cause for this error, I'm also assuming that CURLOPT_POSTFIELDS
doesn't support multidimensional arrays. Is there any other way around this or am I doomed?
Thanks in advance!