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