由于某种原因,我无法通过 cURL 将图像发送到外部服务器。可能是一些小东西,但我一直在看这段代码几个小时,但仍然不知道出了什么问题......
$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);
文本正在通过,如果我在远程服务器上打印出 $_POST 这就是我得到的......
Array (
[fbid] => 12345
[name] => My Name
[email] => email@domain.com
[gender] => male
[title] => Image title
)
任何帮助将不胜感激:P