This is the array of data which i want to post to remote server.
Array
(
[petTitle] => test
[petType] => 2
[breedtype] => dsfsdf
[dateOfBirth] => 14 Apr 2016
[postcode] => 390015
[isPriceNegotiable] => False
[price] => test
[isPublished] => 1
[petQualities] => 2
[petDescription] => test
[username] => XXXX@gmail.com
[file] => Array
(
[0] => Array
(
[name] => Desert.jpg
[type] => image/jpeg
[tmp_name] => D:\xampp\tmp\php1F32.tmp
[error] => 0
[size] => 845941
)
[1] => Array
(
[name] => Koala.jpg
[type] => image/jpeg
[tmp_name] => D:\xampp\tmp\php1F62.tmp
[error] => 0
[size] => 780831
)
)
)
I am using cURL
. However while i send this array with the use of CURLOPT_POSTFIELDS
. it generates a notice "PHP Notice: Array to string conversion".
I am using like this : CURLOPT_POSTFIELDS => $data
. Please refer the curl request below:
$headers = array("Content-Type:multipart/form-data");
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => self::url,
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_ENCODING => "",
CURLOPT_TIMEOUT => 30,
CURLOPT_POST => 1,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => $data,
));
$response = curl_exec($curl);
with this request I am able to post the text data. But somehow I am unable to upload the image and add entry in database.
Any help in this will be highly appreciated.