0

I'm trying to do a curl post request with a $_FILES attachment data that was received.

$header = array('Content-Type: multipart/form-data');
$fields = array('file_contents' => '@' . $_FILES['attachment']['tmp_name']);

$resource = curl_init();
curl_setopt($resource, CURLOPT_URL, $url);
curl_setopt($resource, CURLOPT_HTTPHEADER, $header);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($resource, CURLOPT_POST, 1);
curl_setopt($resource, CURLOPT_POSTFIELDS, $fields);
$result = json_decode(curl_exec($resource));
curl_close($resource);

The request is passing to the second server but without the file. I also double checked the $_FILES in the first server and it's ok but on the second server, it's empty

amit
  • 874
  • 7
  • 16

0 Answers0