Cannot send image through cURL
-
11-12-2019 - |
Question
For some reason I cannot send images through cURL to an external server. Probably something small but i've been looking at this code for hours now and still have no idea whats going wrong...
$ch = curl_init();
$data = array(
'fbid' => $userProfile['id'],
'name' => $userProfile['name'],
'email' => $userProfile['email'],
'gender' => $userProfile['gender'],
'title' => $_POST['title'],
'original' => '@' . UPLOAD_PATH . $imageFilename,
'thumbnail' => '@' . UPLOAD_PATH . $thumbnailFilename,
'cropped' => '@' . UPLOAD_PATH . $croppedImageFilename
);
curl_setopt($ch, CURLOPT_URL, 'http://www.domain.com/curl.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_BINARYTRANSFER,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_exec($ch);
The text is getting through, if I print out $_POST on the remote server this is what I get...
Array (
[fbid] => 12345
[name] => My Name
[email] => email@domain.com
[gender] => male
[title] => Image title
)
Any help would be much appreciated :P
Solution
Forget my last answer. Was too hasty. I believe the issue is that you are looking in $_POST for file uploads. File uploads are contained in $_FILES.
Try dumping the contents of $_FILES on your remote server.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow