HTTP_RANGE nie wznawia pobierania

<?php

//error_reporting(0);




$download = 'http://s52.jakisadres/download/128265050_255103_1308449084_0_9241315151731';



    $remoteFile = $download;

    $ch = curl_init($remoteFile);

    curl_setopt($ch, CURLOPT_NOBODY, true);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    curl_setopt($ch, CURLOPT_HEADER, true);

    $data = curl_exec($ch);

    curl_close($ch);

    if ($data === false) {

    echo 'Plik wygasł!';

    exit;

    }


    if (preg_match('/^HTTP\/1\.[01] (\d\d\d)/', $data, $matches)) {

    $status = (int)$matches[1];

    }

    if (preg_match('/Content-Length: (\d+)/', $data, $matches)) {

    $waga = (int)$matches[1];

    }

    if (preg_match('/filename="(.*)"/', $data, $wynik)){

    $nazwa = trim($wynik[1]);

    }

//print_r($waga);



        $filename = basename($nazwa);

        $file_extension = strtolower(substr(strrchr($filename,"."),1));


        switch( $file_extension ) {

            case "exe":

                $ctype="application/octet-stream";

                break;

            case "rar":

                $ctype="application/x-rar-compressed";

                break;

            case "zip":

                $ctype="application/zip";

                break;

            case "mp3":

                $ctype="audio/mpeg";

                break;

            case "mpg":

                $ctype="video/mpeg";

                break;

            case "avi":

                $ctype="video/x-msvideo";

                break;



            case "php":

            case "htm":

            case "html":

            case "txt":

                die("Bład plik ". $file_extension ." !");

                break;

            default:

                $ctype="application/force-download";

        }



        header("Cache-Control:");

        header("Cache-Control: public");

        header("Content-Type: $ctype");


        $filespaces = str_replace("_", " ", $filename);



        $header='Content-Disposition: attachment; filename='.$filespaces;

        header($header);



        header("Accept-Ranges: bytes");


        $size = $waga;  


        if(isset($_SERVER['HTTP_RANGE'])) {



            $seek_range = substr($_SERVER['HTTP_RANGE'] , 6);

            $range = explode( '-', $seek_range);

            if($range[0] > 0) { $seek_start = intval($range[0]); }

            if($range[1] > 0) { $seek_end = intval($range[1]); }


            header("HTTP/1.1 206 Partial Content");

            header("Content-Length: " . ($seek_end - $seek_start + 1));

            header("Content-Range: bytes $seek_start-$seek_end/$size");

        } else {

            header("Content-Range: bytes 0-$seek_end/$size");

            header("Content-Length: $waga");

        }  


    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $download);

    curl_exec($ch);

curl_close($ch);


?> 

[/code]

niestety niewiem czemu nie wznawia mi połączenie jak zerwie się trzeba potem od nowa pobierać

krysia5522 , nazwij temat konkretnie, bez zbędnych problemów w tytule. Zapoznaj się z regulaminem forum.