2012-08-27 27 views
1

나는 얼마 전 curl을 사용하여 일하는 작은 응용 프로그램을 작성했습니다. 오늘 나는 그것을 시험해 보려고 노력했지만 그것은 효과가 없다.PHP의 컬 (curl)이 서버에 데이터를 게시하지 않았습니다.

컬을 사용하여 외부 서버에있는 다른 페이지에 데이터를 게시합니다. Get은 작동하지만 게시물은 작동하지 않습니다.

업데이트 1 : 나는 아래로 "SOME_KEY"라는 항목을 갖는 값이 " '@C : /wamp/www/name.pdf'"데 오류를 좁혀

게시물 배열을 이 소문이 생길 것이다.

@ symbole이 문제를 일으키는 방법 !!! 나는 대답 아래

확인 해결 서버

에 파일을 uplaod 노력하고 있어요.

원래 항목

나의 현재 컬 옵션

$curl_options = array(
     CURLOPT_RETURNTRANSFER => true,     // Return web page  
     CURLOPT_HEADER   => false,    // Don't return headers 
     CURLOPT_FOLLOWLOCATION => false,    // Follow redirects 
     CURLOPT_ENCODING  => "",     // Handle all encodings 
     CURLOPT_AUTOREFERER => false,    // Set referer on redirect 
     CURLOPT_CONNECTTIMEOUT => 120,     // Timeout on connect 
     CURLOPT_TIMEOUT  => 120,     // Timeout on response 
     CURLOPT_MAXREDIRS  => 0,     // Stop after 10 redirects 
     CURLOPT_USERAGENT  => "regify connector", // Who am I? FIREFOX, IE, OPERA, CHROME, SPIDER, SEARCH BOT...etc. 
    ); 

기능이 게시물 데이터 :

function makePostRequest($url, $fields ){ 

     //Create the options 
     //global $curl_options; 
     $curl_options[CURLOPT_URL  ] = $url; 
     $curl_options[CURLOPT_POST  ] = count($fields); 
     $curl_options[CURLOPT_POSTFIELDS] = $fields; 

     $ch = curl_init(); 
     curl_setopt_array($ch, $curl_options); 

     $content = curl_exec ($ch); 
     $err  = curl_errno($ch); 

     curl_close($ch);  
     return ($err == 0)?$content:false; 
    } 

PHP의 getallheader이

array 
    'Host' => string 'localhost' (length=9) 
    'Accept' => string '*/*' (length=3) 
    'Content-Length' => string '16632433' (length=8) 
    'Expect' => string '100-continue' (length=12) 
    'Content-Type' => string 'multipart/form-data; boundary=----------------------------93ac4fed717b' (length=70) 
을 반환

CURL의 curl_getinfo 기능은 반환 :

array 
    'url' => string 'http://localhost/archieve/index.php' (length=35) 
    'content_type' => string 'application/json' (length=16) 
    'http_code' => int 200 
    'header_size' => int 281 
    'request_size' => int 263 
    'filetime' => int -1 
    'ssl_verify_result' => int 0 
    'redirect_count' => int 0 
    'total_time' => float 0.125 
    'namelookup_time' => float 0 
    'connect_time' => float 0 
    'pretransfer_time' => float 0 
    'size_upload' => float 16632433 
    'size_download' => float 18 
    'speed_download' => float 144 
    'speed_upload' => float 133059464 
    'download_content_length' => float 18 
    'upload_content_length' => float 16632433 
    'starttransfer_time' => float 0.015 
    'redirect_time' => float 0 
    'certinfo' => 
    array 
     empty 

이 porblem 콘텐츠 유형에 따라 원인이 될 수 있을까? 나는 CURL이이 값을 그 자체로 설정할만큼 똑똑하다는 것을 recommanded했다고 stackoverflow에서 읽었다.

답변

1

알아 냈습니다. 코드는해야만하고 여전히 작동했습니다. 컬 (Curl)은 PDF 파일을 게시 할 수 없었습니다. 사용 권한 때문에 믿을 수 없으므로 전혀 게시하지 않았습니다.

+1

print_r은 (는) 친구입니다 –

+0

curl_errno ($ ch); 문제는 POST 데이터가 제출되지 않은 것을 제외하고는 모든 것이 정상적으로 작동한다는 것이 었습니다. – thedethfox

관련 문제