Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

Limit bandwidth speed with PHP

My server is now delevering downloads at 1 Mb/s.  That is way to fast and I want to slow this down to 20 1 Kb/s.

How can I do this?
<?php
 
$file = 'movie.mov';
 
if (file_exists($file)) {
    header('Content-Description: File Transfer');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename='.basename($file));
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($file));
    ob_clean();
    flush();
    readfile($file);
    exit;
}
?>

Open in new window

SOLUTION
Avatar of Chris Harte
Chris Harte
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hankknight

ASKER

More creativity, please.  This can be done with PHP!  Send a few bytes, sleep, send a few more bytes, sleep, ect.

What is the most resource efficient way to do this?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial