I have the following code which works just fine sending the $xml. However when i try to add a file to be sent with the xml as well i get an error. I tried using a postData array but then got an array to string error. The way i have it now works but it only sends the xml not the file. Any ideas on how I can send the @file with the postfields? Any help is appreciated
$header = array('Content-Type: multipart/form-data');
$xml['xml'] = '<UploadPhoto>';
$xml['xml'] .= '<ID>12345</ID>';
$xml['xml'] .= '<PhotoID>myphoto</PhotoID>';
$xml['xml'] .= '<Filename>myphoto.jpg</Filename>';
$xml['xml'] .= '<Instructions>Need cheeks less rosy</Instructions>';
$xml['xml'] .= '</UploadPhoto>';
$postData = array(
'file' => '@/myphoto.jpg',
'xml' => $xml
);
}
$connection = curl_init();
curl_setopt($connection, CURLOPT_URL, "http://www.myurl.com/api");
curl_setopt($connection, CURLOPT_HTTPHEADER, $header);
curl_setopt($connection, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($connection, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($connection, CURLOPT_POST, 1);
curl_setopt($connection, CURLOPT_POSTFIELDS, $xml);
curl_setopt($connection, CURLOPT_RETURNTRANSFER, 1);
set_time_limit(108000);
$output = curl_exec($connection);
curl_close($connection);
print_r($output);