2

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 protected]
    [gender] => male
    [title] => Image title
)

Any help would be much appreciated :P

1
  • Are you using multipart/form-data or the standard application/x-www-form-urlencoded? Commented May 18, 2012 at 19:34

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.