2009/10/13 Andrea Giammarchi <an_red@xxxxxxxxxxx>: > >> $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); If you're re-using a curl handle then it may be a good idea to set these explicitly. However, these are also the default values so it's not really necessary to set them for a new handle. You're right that it's a good idea to include the 'b' in the fopen() mode. > curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0); I wouldn't recommend setting this to 0 unless you're very sure that the connection will succeed; otherwise, your script will hang indefinitely waiting for the connection to be made. Regards, Torben > 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. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php