//$request_header = array('Accept-Ranges:bytes',"content-disposition:attachment; filename=".$url); //curl_setopt($curl, CURLOPT_HTTPHEADER, $request_header); $buffer = curl_exec($curl); $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE); curl_close($curl); if ((int) $httpCode != 206) { die("download file error"); } //将下载的文件写入本地 $file = fopen($this->dest, 'a'); if (!$file) { die("open file error"); } fwrite($file, $buffer); fclose($file); flush(); file_put_contents("./cfg", base64_encode(serialize(array("downed" => $end, "totel" => $this->total_file_size)))); echo PHP_EOL . 'download:' . (int) ($end * 100 / $this->total_file_size) . "%"; $begin = $end + 1; } echo PHP_EOL . 'download complete'; } } //设置下载地址 $url = "https://github.com/docker/toolbox/releases/download/v1.11.1/DockerToolbox-1.11.1.exe"; //$url = "http://113.215.11.151/dlied1.qq.com/lol/dltools/LOL_V3.1.8.3_FULL_TDL_signed.exe?mkey=570c465793a2742e&f=1b0c&p=.exe"; //设置下载的文件存储路径 $dest = "./DockerToolbox-1.11.1.exe"; $downer = new HttpDown($url, $dest); $downer->download();