How to limit download speed with php?

Discussion in 'PHP' started by BLaZeR, Jan 28, 2007.

  1. #1
    Is there a script that does that? Any help would be appreciated.
     
    BLaZeR, Jan 28, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    nico_swd, Jan 28, 2007 IP
  3. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    CodyRo, Jan 29, 2007 IP
  4. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I worked on a very high traffic site and the whole thing was running slowly since there was a massive mod database eating up all the bandwidth. It was running on IIS and we setup files.domain.com with a bandwidth cap and moved all the images and files onto it. Pages loaded quickly while download speed on files were limited.

    As Cody said, that's something you want your server to handle. I wouldn't attempt it with PHP unless you really have no choice.
     
    rodney88, Jan 29, 2007 IP
  5. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #5
    
    $speed = 20; //in KB
    
    $file = fopen($file_location,'r');
    while($temp = fread($file,round($speed*1024))){
        echo $temp;
    	flush();
    	sleep(1);
    }
    fclose($file);
    
    PHP:
    Peace,
     
    Barti1987, Jan 29, 2007 IP
  6. BLaZeR

    BLaZeR Peon

    Messages:
    1,567
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Ooh,thanks.
     
    BLaZeR, Jan 30, 2007 IP