2011-06-05 24 views
8

Bir sunucuya görüntü dosyası göndermeye çalışıyorum. Başlangıçta evimde proxy olmadan komutumu test ettim ve iyi çalıştı. Ama aynı senaryoyu üniversitemde kullandığımda bazı hatalar atıyor. görüntüleri yüklemek için fonksiyonBir proxy arkasındaki curl post dosyası hata döndürüyor

function upload($filepath,$dir) 

{ 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_VERBOSE, 0); 
    curl_setopt($ch, CURLOPT_PROXY, 'localhost:7777'); 
    curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'ae07b026:kpack'); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)"); 
    curl_setopt($ch, CURLOPT_POST, true); 
    curl_setopt($ch, CURLOPT_URL, 'http://finalytics.in/sites/scrap/uploader.php'); 
    $post_array = array(
     "my_file"=>"@".$filepath, 
     "upload"=>"Upload", 
     "dir"=>$dir 
    ); 
    print_r($post_array); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array); 
    $response = curl_exec($ch); 
    echo $response; 

} 

aşağıdaki gibi olup uploader.php sadece görüntüyü kaydeder normal dosyasıdır. Ben alıyorum

hata sorunu "KALAMAR" dir kullanılarak vekil dışarı enstitü bu

 ERROR 
    The requested URL could not be retrieved 

While trying to process the request: 

    POST /sites/scrap/uploader.php HTTP/1.1 
    Proxy-Authorization: Basic YWUwN2IwMjY6a3BhY2s= 
    User-Agent: Mozilla/4.0 (compatible;) 
    Host: finalytics.in 
    Accept: */* 
    Proxy-Connection: Keep-Alive 
    Content-Length: 87022 
    Expect: 100-continue 
    Content-Type: multipart/form-data; boundary=----------------------------07ae68105e71 


The following error was encountered: 

    Invalid Request 

Some aspect of the HTTP Request is invalid. Possible problems: 

    Missing or unknown request method 
    Missing URL 
    Missing HTTP Identifier (HTTP/1.0) 
    Request is too large 
    Content-Length missing for POST or PUT requests 
    Illegal character in hostname; underscores are not allowed 

Your cache administrator is webmaster. 
Generated Sun, 05 Jun 2011 17:26:33 GMT by proxy1.iitm.ac.in (squid/2.7.STABLE7) 
+0

Sadece bir tahmin ekleyebilirsiniz, ancak üniversite vekil localhost'unuzda üzerinde gerçekten lütfen? – konsolenfreddy

+0

değil, ben akademik proxy tünel ve kullanarak. –

cevap

12

gibidir. Ve Squid, Beklemeyi desteklemiyor: 100-devam et.

Sonunda benim seçenekleri

curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); 

ve tüm çalışma ince bu ekledi.

1

yukarıdaki çözüm işe yaramazsa

curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type: multipart/form-data",'Expect: ')); 
İlgili konular