the code work only in the localhost

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
trazan
Forum Newbie
Posts: 15
Joined: Fri Nov 13, 2009 8:41 pm

the code work only in the localhost

Post 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]
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: the code work only in the localhost

Post by Christopher »

Probably the file path in $filename is incorrect.
(#10850)
trazan
Forum Newbie
Posts: 15
Joined: Fri Nov 13, 2009 8:41 pm

Re: the code work only in the localhost

Post 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
trazan
Forum Newbie
Posts: 15
Joined: Fri Nov 13, 2009 8:41 pm

Re: the code work only in the localhost

Post 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
Post Reply