Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with curl to send Content-length header
    text
    copied!<p>i need to upload files to wupload here is my function</p> <pre><code>public function doPost($link, $postfields = '', $cookie = '', $ref = '', $nobody = false, $upload = false, $header = true, $headers = "") { $ch = curl_init($link); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if ($header) curl_setopt($ch, CURLOPT_HEADER, 1); if ($headers) curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_REFERER, $ref); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1'); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); curl_setopt($ch, CURLOPT_UNRESTRICTED_AUTH, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_VERBOSE, TRUE); if ($postfields) { curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); } if ($cookie) { curl_setopt($ch, CURLOPT_COOKIE, $cookie); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); } $log = fopen("log.txt", "w+"); curl_setopt($ch, CURLOPT_STDERR, $log); if ($upload) curl_setopt($ch, CURLOPT_UPLOAD, true); $page = curl_exec($ch); curl_close($ch); fclose($log); return($page); } </code></pre> <p>and i tried to make this call</p> <pre><code> $result = doPost("http://www.wupload.com/file-manager/list", '', $this-&gt;upcookies, "http://www.wupload.com/", false); preg_match("/_uploadServerHostname = '(s[0-9]*.wupload.com)'/i", $result, $matches); $server = $matches[1]; $post = array(); $post['files[]'] = "@$filelocation"; $headers = array('Content-Type: application/octet-stream','Content-length: ' . filesize($filelocation)); $page = $this-&gt;doPost($server, $post, $this-&gt;upcookies, "http://www.wupload.com", false, true, true, $headers); </code></pre> <p>and the result is</p> <pre><code>HTTP/1.1 411 Length Required Server: nginx Date: Sun, 21 Aug 2011 16:10:51 GMT Content-Type: text/html Content-Length: 174 Connection: close </code></pre> <p>i thought i sent the content lenght, cookies and file are ok. to be more clear, here is the curl log for this call</p> <pre><code>* About to connect() to s206.wupload.com port 80 (#0) * Trying 78.140.153.43... * connected * Connected to s206.wupload.com (78.140.153.43) port 80 (#0) &gt; PUT / HTTP/1.1 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1 Host: s206.wupload.com Accept: */* Referer: http://www.wupload.com Transfer-Encoding: chunked Cookie: fs_orderFoldersDirection=asc; fs_orderFoldersBy=name; isAffiliate=1; nickname=soussouheros; email=avix%40live.fr; rememberMe=1; PHPSESSID=96aeh7liqt5p4u4d98at7acv71; role=premium; lang=en; visitSourceUrl=http%3A%2F%2Fwupload.com%2F; C:\wamp\www\tuto\brazzo/temp/wu.up &lt; HTTP/1.1 411 Length Required &lt; Server: nginx &lt; Date: Sun, 21 Aug 2011 16:10:51 GMT &lt; Content-Type: text/html &lt; Content-Length: 174 &lt; Connection: close &lt; * Closing connection #0 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload