Hope this is helpful:
<?php $headers = array('token: pacexpressx1x2x3j' ); $data = array( "STATUS" => "insert" , "NAME" => utf8_encode("Test integration 10"), "COD_AREA" => "4", "DESC_AREA_" => utf8_encode("info/IT"), "JOB" => utf8_encode("TEST job"), "COMPANY" => "4", "DESC_COMPANY" => utf8_encode("XPTO1"), "file" => '@/home/user/test.png'); $url = 'your_link'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $output = curl_exec($ch); echo($output) . PHP_EOL; curl_close($ch);
In this example, I am posting the header and posting the fields.
$ headers => I put the value of the token in an array to show how you can send the value.
$ data => I used an array with some view values.
In curl, I used here variebles: curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data_string ); curl_setopt ($ ch, CURLOPT_HTTPHEADER, $ headers );
CURLOPT_POSTFIELDS -> full data for publishing in HTTP "POST" mode. To publish the file, add the file name with @ and use the full path. A file type can be explicitly specified by following a file name with a type in the format '; type = mimetype '. This parameter can be passed as a string with urlencoded, such as "para1 = val1 & para2 = val2 & ..." or as an array with the field name as the key and field data as the value. If the value is an array, the Content-Type header will be set to multipart / form-data. Starting with PHP 5.2.0, the value must be an array if files are passed to this parameter with the @ prefix.
If you want to know more about curl_setopt, I give you the link: http://php.net/manual/pt_BR/function.curl-setopt.php
To find out what you are sending and receiving the file you sent, you can use this code below:
echo 'Here is some more debugging info:'; echo "\n<hr />\n"; print_r($_FILES); echo "\n<hr />\n"; print_r($_POST); print "</pr" . "e>\n"; echo "\n<hr />\n"; // here you will record the file in your server... you can choose a directory if you want file_put_contents($_FILES['file']['name'],file_get_contents($_FILES['file']['tmp_name']));