0

This is my curl code from postman:

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_PORT => "2403",
  CURLOPT_URL => "http://".cfg('api_ip')."/sk_group/update_profile_pic",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n{\"groupId\":\"Group|1\",\"profile_pic\":\"image.jpg\"}\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"profile_pic\"; filename=\"image.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
  CURLOPT_HTTPHEADER => array(
    "cache-control: no-cache",
    "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
    "sessionid: 876523451721001",
    "versioncode: 1"
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

How to send file from my input file to the profile_pic in post fields? I already searching many times in google, but i dont have done yet, anyone who know how.. please help me...

Only get response error curl Empty reply from server

If file posted.., the file on server always 0kb size

0 Answers0