2
由于某些原因,我无法通过cURL将图像发送到外部服务器。可能是一些小的,但我一直在这个代码小时现在正在寻找,仍然不知道怎么回事错误...无法通过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 protected]
[gender] => male
[title] => Image title
)
任何帮助将非常感激:P
你使用'multipart/form-data'还是标准的'application/x-www-form-urlencoded'? – 2012-05-18 19:34:40