By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,640 Members | 2,597 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,640 IT Pros & Developers. It's quick & easy.

Bandwidth/Download Limit

P: n/a
Hello,

I'd like to make some download speed limitation on some of my files
using PHP. I know that an Apache module can do that, but i cannot access
my ISP Apache configuration.

My idea was to put the file into a .htaccess protected diretory and to
build a "proxy" with PHP.

I can also put a download limit (after n download per day the script
deny download). Any idea or known script doing that?

Thank you in advance,

Nicolas

Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Nicolas C. <cuicui.NO-SPAM.@noos.fr> wrote:
I'd like to make some download speed limitation on some of my files
using PHP. I know that an Apache module can do that, but i cannot access
my ISP Apache configuration.

My idea was to put the file into a .htaccess protected diretory and to
build a "proxy" with PHP.


Perfectly possible. Keep the files in a protected area, create an array
with locations and call a php script with an array index to get the
file. Read the file in a buffer (eg 4k) and sleep 1 sec, my simple logic
says that the browser will get a max transfer of 4kb/s in this example:

$fp=fopen($file,'r')
while(!feof($fp))
{
echo fgets($fp,4096);
sleep(1);
}
fclose($fp);

BTW don't forget to set an appropriate mimetype, and do extensive
errorcatching.

--

Daniel Tryba

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.