curl-and-php
Re: If statements inside PHP Curl Writefunction
Date: Mon, 6 Aug 2012 16:33:50 +0100
Thanks that did help, it is now calculating all the way to the end, however
there is some strange math going on here. I downloaded a 300mb file and the
reported size is 500mb?
I've tried this various ways now, calculating results as bits and bytes and
it refuses to come out correct.
I'm gonna cut my losses and presume this functionality is not available in
curl.
Instead I will calculate how much a user has downloaded by adding it all up
after the server has finished downloading the file.
Thanks.
On 6 August 2012 11:10, <curl-and-php_at_latter.org> wrote:
> On 05/08/12 19:43, Jake Cattrall wrote:
>
>>
>> curl_setopt($ch, CURLOPT_WRITEFUNCTION, function($ch, $chunk) {
>> $chunksize = strlen($chunk);
>> $downloaded .= $chunksize;
>>
>
> I think you need to declare $downloaded as static, initialise it, and
> then $downloaded += $chunksize;
>
> With ".=" it's doing a string concatenation.
>
>
> if($downloaded > $milestone){
>> echo "milestone";
>> $downloaded = 0;
>>
>
> $downloaded -= $milestone;
> ______________________________**_________________
> http://cool.haxx.se/cgi-bin/**mailman/listinfo/curl-and-php<http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php>
>
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-php
Received on 2012-08-06