Jump to content

Jfergy

New Members
  • Posts

    3
  • Joined

  • Last visited

Jfergy's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Yes, but my question is not how they are responding its how I send an image file in an array with xml via curl. This is a question on my side not theirs.
  2. The API is controlled by another party and output is not given other than to say the file is not sent. In sending the XML its posting properly by itself. The real issue for me is combining the xml post data with an actual file as well. Im sorry I dont have much more than that as the API im working with is not great. However, its good enough to know I did not send it a file when I just send the xml. Output right now simply states no file uploaded with order.
  3. 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);
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.