steviez Posted December 30, 2007 Share Posted December 30, 2007 Hi, I am trying to develop a file hosting script for my site and need the following feature but need to know if it can be done with PHP? I need to limit the speed of downloads for non premium users and only let them download so much in a certen period. Can this be done and if so can anyone point me in the right direction? Thanks Link to comment https://forums.phpfreaks.com/topic/83735-is-this-possable-with-php/ Share on other sites More sharing options...
steviez Posted January 5, 2008 Author Share Posted January 5, 2008 Anyone know of a way this is done? Link to comment https://forums.phpfreaks.com/topic/83735-is-this-possable-with-php/#findComment-430852 Share on other sites More sharing options...
papaface Posted January 5, 2008 Share Posted January 5, 2008 <?php $file = "test.mp3"; // file to be send to the client $speed = 8.5; // 8,5 kb/s download rate limit if(file_exists($file) && is_file($file)) { header("Cache-control: private"); header("Content-Type: application/octet-stream"); header("Content-Length: ".filesize($file)); header("Content-Disposition: filename=$file" . "%20"); flush(); $fd = fopen($file, "r"); while(!feof($fd)) { echo fread($fd, round($speed*1024)); flush(); sleep(1); } fclose ($fd); } ?> Google is amazing Link to comment https://forums.phpfreaks.com/topic/83735-is-this-possable-with-php/#findComment-430857 Share on other sites More sharing options...
steviez Posted January 5, 2008 Author Share Posted January 5, 2008 Maybe i have been looking for the wrong thing thanks ill give it a try! Link to comment https://forums.phpfreaks.com/topic/83735-is-this-possable-with-php/#findComment-430865 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.