Page 1 of 1

the code work only in the localhost

Posted: Tue Nov 24, 2009 9:59 pm
by trazan
i use this code to make a download page and hide the link and limit the speed of download
it's work on the localhost Perfectly But when i try to use it on my site the page still loading forever and the download does not start
can u help me ??

Code: Select all

header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private",false); 
        header('Accept-Ranges: bytes');
                header('HTTP/1.1 206 Partial Content');
        header("Content-Transfer-Encoding: binary");
                header("Content-length: ".filesize($filename));
                header("Content-type: $filetype"); 
         header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\"");
 $file = fopen($filename, "r");    
    while(!feof($file)) {
 
        // send the current file part to the browser
        echo fread($file, round($download_rate * 1024));    
 
        // flush the content to the browser
        flush();
 
        // sleep one second
        sleep(1);    
    }      
// close file stream
    fclose($file);  
[/b]

Re: the code work only in the localhost

Posted: Wed Nov 25, 2009 12:40 am
by Christopher
Probably the file path in $filename is incorrect.

Re: the code work only in the localhost

Posted: Wed Nov 25, 2009 2:26 am
by trazan
i am sorry it was my mistake
but now i have a problame with the archive files like ( rar , zip ...etc )
when i download it with this code and try to extract it i find an error

Re: the code work only in the localhost

Posted: Wed Nov 25, 2009 2:59 am
by trazan
trazan wrote:i am sorry it was my mistake
but now i have a problame with the archive files like ( rar , zip ...etc )
when i download it with this code and try to extract it i find an error
and it's only happend if i pused the download and resume it again
do you have the solution for this bug