Cakephp cURL send file


Im trying to send two files vie Curl but I always get the response:

string(97) “{“StatusId”:-1,“Success”:false,“ReturnObject”:null,“Message”:“You must upload at least one file”}”

From the API.

Can you tell me if my code looks good and what the reason could be as to why the API keeps returning this message? In the next block of code I attach the documents to an email and that works fine so why does the cURL post think there are no files being sent?

 >    // initialise the curl request
   $post = array(
'ClientId' => $client,
'Document1'=> '@'.WWW_ROOT.'img/uploads/documents/'.$newfilename.';type=application/pdf',
'Document2'=> '@'.WWW_ROOT.'img/uploads/documents/'.$newfilename2.';type=application/pdf'


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, “”);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);

$json = json_decode($result);

This doesn’t really have anything to do with CakePHP (save the WWW_ROOT constant). You might be better off posting this on Stack Overflow.

That said, it looks like it might be a problem communicating with the host API you’re trying to upload to, since it’s returning a result and message to you.