2012-05-18 63 views
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

+0

你使用'multipart/form-data'還是標準的'application/x-www-form-urlencoded'? – 2012-05-18 19:34:40

回答

1

忘了我最後的答案。太倉促了。我相信問題在於您正在尋找文件上傳的$ _POST。文件上傳包含在$ _FILES中。

嘗試在遠程服務器上轉儲$ _FILES的內容。

+0

呃,愚蠢的錯誤。感謝您的幫助,雖然:) – endaquigley