php indir sorun

0 Cevap php

howdy: I am working on a program with php to download files. the script request is like: http://127.0/download.php?file=abc.zip I use some script mentioned in link text

it definitely works for files under 300M, either multithread or single-thread download, but, when i try to download a file >300M, I get a problem in single-thread downloading, I downloaded only about 250M data, then it seems like the http connection is broken. it doesnot break in the break-point ..Why? debugging the script, I pinpointed where it broke:

        $max_bf_size = 10240;
        $pf = fopen("$file_path", "rb");
        fseek($pf, $offset);
        while(1)
        {
            $rd_length = $length < $max_bf_size? $length:$max_bf_size;
            $data = fread($pf, $rd_length);
            print $data;
            $length = $length - $rd_length;
            if( $length <= 0 )
            {
                //__break-point__ 
                break;
            }

        }

Her istenen belge sadece echo veya print için 250M veri tamponunu almak gibi bu görünüyor .. Ama bir dosya indirmek için bir multi-thread kullandığınızda çalışır

Bir çok Dan

0 Cevap