Quantcast
Channel: FastCGI Module
Viewing all articles
Browse latest Browse all 205

Function Sleep and speed limit download

$
0
0

Hello!

I Russian, sorry for my bad English! Smile

My PHP-script get files, but I need speed limit to download.
For this I use sleep() function. But I have a bad effect!
When the download starts
1) Browser tab going for a long time (from 30 seconds to 1 minute)
2) Loading begins at the right speed
3) Download suited to a specific point* and stops
4) The browser reports a problem with the connection

*specific point - multiple of the value of the variable$download_rate (limiting speed). See code. If $download_rate = 100, download stoped on 10 Mb of file, if 50 - 5 Mb...

This problem is only on IIS, Apache all right! Frown Withoutsleepallrighttoo!

PHP-code:

<?php$file = 'video.avi';
set_time_limit(0);
ob_end_clean();$download_rate = 100; // speed limit kb/s$fd = fopen($file, 'rb'); // Open file from read

// HTTP-headers code... (cut)

while (!feof($fd))
{ 
print fread($fd, $download_rate * 1024); // read block file ang out

sleep(1); // sleep 1 second
}

fclose($fd);
exit;
?>

Technical information:

Web-Server: IIS 7.5

OS: Windows Server 2008 R2 x64 SP1

PHP: v5.6.9 Win32 VC11 x64

Browser: not important

Please, Help me!


Viewing all articles
Browse latest Browse all 205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>