cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

If statements inside PHP Curl Writefunction

From: Jake Cattrall <contact_at_websiteforge.co.uk>
Date: Sun, 5 Aug 2012 19:43:24 +0100

In my function here I am trying to perform functions when files are
downloaded past certain milestones. So in this instance I want to download
10mb, then echo milestone, then repeat again to the next 10mb.

The file I'm downloading is about 300mb, so I'd expect the function to be
called 30 times.

What does milestone need to be? bytes? kilobytes? Whatever it is, if I go
beyond about 10000, it no longer calls anything inside that if.

curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($ch, $chunk) {
$chunksize = strlen($chunk);
$downloaded .= $chunksize;
if($downloaded > $milestone){
    echo "milestone";
    $downloaded = 0;
}
return $chunksize;
});

_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2012-08-05