<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Code The World — File download with speed limit]]></title>
	<link rel="self" href="https://codetheworld.com/extern.php?action=feed&amp;tid=34&amp;type=atom" />
	<updated>2008-06-15T11:47:01Z</updated>
	<generator>PunBB</generator>
	<id>https://codetheworld.com/viewtopic.php?id=34</id>
		<entry>
			<title type="html"><![CDATA[Re: File download with speed limit]]></title>
			<link rel="alternate" href="https://codetheworld.com/viewtopic.php?pid=124#p124" />
			<content type="html"><![CDATA[<p>Yeh that would be cool</p>]]></content>
			<author>
				<name><![CDATA[69]]></name>
				<uri>https://codetheworld.com/profile.php?id=142</uri>
			</author>
			<updated>2008-06-15T11:47:01Z</updated>
			<id>https://codetheworld.com/viewtopic.php?pid=124#p124</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: File download with speed limit]]></title>
			<link rel="alternate" href="https://codetheworld.com/viewtopic.php?pid=118#p118" />
			<content type="html"><![CDATA[<p>Nice post, but I was wondering if you can show us how to limit variable download, like between 20,5 kb and 40,00 kb?</p>]]></content>
			<author>
				<name><![CDATA[Sancho Panssa]]></name>
				<uri>https://codetheworld.com/profile.php?id=144</uri>
			</author>
			<updated>2008-06-15T10:47:15Z</updated>
			<id>https://codetheworld.com/viewtopic.php?pid=118#p118</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[File download with speed limit]]></title>
			<link rel="alternate" href="https://codetheworld.com/viewtopic.php?pid=45#p45" />
			<content type="html"><![CDATA[<p>This snippet shows you how to limit the download rate of a file download. <br /></p><div class="codebox"><pre><code>// local file that should be send to the client
$local_file = &#039;test-file.zip&#039;;
// filename that the user gets as default
$download_file = &#039;your-download-name.zip&#039;;
 
// set the download rate limit (=&gt; 20,5 kb/s)
$download_rate = 20.5; 
if(file_exists($local_file) &amp;&amp; is_file($local_file)) {
    // send headers
    header(&#039;Cache-control: private&#039;);
    header(&#039;Content-Type: application/octet-stream&#039;); 
    header(&#039;Content-Length: &#039;.filesize($local_file));
    header(&#039;Content-Disposition: filename=&#039;.$download_file);
 
    // flush content
    flush();    
    // open file stream
    $file = fopen($local_file, &quot;r&quot;);    
    while(!feof($file)) {
 
        // send the current file part to the browser
        print fread($file, round($download_rate * 1024));    
 
        // flush the content to the browser
        flush();
 
        // sleep one second
        sleep(1);    
    }    
 
    // close file stream
    fclose($file);}
else {
    die(&#039;Error: The file &#039;.$local_file.&#039; does not exist!&#039;);
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Rockers00]]></name>
				<uri>https://codetheworld.com/profile.php?id=24</uri>
			</author>
			<updated>2008-06-15T03:48:59Z</updated>
			<id>https://codetheworld.com/viewtopic.php?pid=45#p45</id>
		</entry>
</feed>
