Greetings, I'm trying to download file to my server using curl but I am unable to get it working like I want possibly for the reason that cookie header is not sent correctly. here's my code: $head .= "Cookie: user=xxxxxxxx-xxxxxxxx"; $ch = curl_init(); curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/ Firefox 2.0.0.11, ProductSub: 20071127, RV version: 1.8.1.11'); curl_setopt($ch, CURLOPT_FILE, $out); curl_setopt($curl, CURLOPT_HTTPHEADER, $head); curl_setopt($ch, CURLOPT_URL, $file); PHP: its downloading html page while it should be downloading the file
Try: curl_setopt($ch, CURLOPT_COOKIE, 'user=xxxxxxxx-xxxxxxxx'); PHP: EDIT: Your version could possibly work too. There's a small error: curl_setopt($curl, CURLOPT_HTTPHEADER, $head); PHP: It should be $ch, not $curl.
Great, its working thanks but I face another problem now its redirecting after accepting the cookie variables to other link and the file ends up as 300byte redirection headers
the code: <?php get_rapidshare("http://rapidshare.com/files/86205767/Pro_PHP_XML_and_Web_Services.rar", "/", "xyz3.rar"); function get_rapidshare($file, $path, $filename) { echo "<br>Attempting message download for $file<br>"; $out = fopen($filename, 'wb'); $ch = curl_init(); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //like you told curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/ Firefox 2.0.0.11, ProductSub: 20071127, RV version: 1.8.1.11'); curl_setopt($ch, CURLOPT_FILE, $out); curl_setopt($ch, CURLOPT_COOKIE, 'user=xxxx-xxxx'); curl_setopt($ch, CURLOPT_URL, $file); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt ($ch, CURLOPT_HEADER, 1); curl_exec($ch); curl_close($ch); } ?> PHP: here's what I get HTTP/1.1 302 Moved Temporarily P3P: CP="ALL DSP COR CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa CONa TELa OUR STP UNI NAV STA PRE" Date: Mon, 25 Feb 2008 07:59:07 GMT Connection: close Accept-Ranges: bytes Location: http://rs181l32.rapidshare.com/files/54852047/Pro_PHP_XML_and_Web_Services.rar Content-Length: 0 PHP: