?
Solved

Limit bandwidth speed with PHP

Posted on 2009-04-20
3
Medium Priority
?
315 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:hankknight
3 Comments
 
LVL 17

Assisted Solution

by:Chris Harte
Chris Harte earned 400 total points
ID: 24185252
You cannot do this with php.
This has to be done on the server.
Here is a link to show how it can be done on Apache
http://www.webhostgear.com/279.html

0
 
LVL 16

Author Comment

by:hankknight
ID: 24185303
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?
0
 
LVL 11

Accepted Solution

by:
Chris Gralike earned 1600 total points
ID: 24185508
Sure this can be done with php if your goal is to rewrite QoS using PHP. In any account i dont think this solution will be anything near to "Whats the most efficient way to do this"

When making a sidestep on the subject, and you are trying to recreate something like this..
http://www.fileshack.com/login.x
Then your approach is a off ;-). In that case you need something like this...
http://www.filecart.com/details/16264/486/Personal_File_Server.php
Rgrds,
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
It’s a season to be thankful, and we’re thankful for users like you who engage on site, solve technology problems, and network with others in the industry. What tech are we most thankful for? Keep reading.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 16 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question