RE: How to bypass (pipe) curl_exec return value directly to a file?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




>   $ch = curl_init($url);
>   $fp = fopen('/tmp/curl.out', 'w');
>   curl_setopt($ch, CURLOPT_FILE, $fp);
>   curl_exec($ch);
> 
> Error checking etc. is of course left up to you. :)

oops, I sent directly the file name. Let me reformulate the code then:


set_time_limit(0);
$fp = fopen('stream.bin', 'wb');
$ch = curl_init($siteURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, false);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_FILE, $fp);
curl_exec($ch);
fclose($fp);

Apologize I did not test it before.

Regards

 		 	   		  
_________________________________________________________________
Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail you.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux