1.功能:支持断点续传的下载,能计算传输率,能控制传输率
简易使用方法:
$object = new httpdownload(); $object->set_byfile($file)%N#H#%;//服务器文件名,包括路径 $object->filename = $filename;//下载另存为的文件名 $object->download();
3.源文件:
<? class httpdownload { var $data = null; var $data_len = 0; var $data_mod = 0; var $data_type = 0; var $data_section = 0; //section download var $sentSize=0; var $handler = array(''auth'' => null); var $use_resume = true; var $use_autoexit = false; var $use_auth = false; var $filename = null; var $mime = null; var $bufsize = 2048; var $seek_start = 0; var $seek_end = -1; var $totalsizeref = 0; var $bandwidth = 0; var $speed = 0; function initialize() { global $HTTP_SERVER_VARS; if ($this->use_auth) //use authentication { if (!$this->_auth()) //no authentication { header(''WWW-Authenticate: Basic realm="Please enter your username and password"''); header(''HTTP/1.0 401 Unauthorized''); header(''status: 401 Unauthorized''); if ($this->use_autoexit) exit(); return false; } } if ($this->mime == null) $this->mime = "application/octet-stream"; //default mime |