|
|
发表于 2019-10-11 22:10:36
|
显示全部楼层
本帖最后由 yabuy 于 2019-10-11 23:06 编辑
谷歌搜索找了个自己改下代码,大家需要就拿去吧
[ol] 1)) { $speed = $current / ($temptime2 - $inittime); $formatespeed = RealSize($speed) . '/s'; $formatetotal = RealSize($total); $formatecurrent = RealSize($current); $pasttime = '已用时:' . round($temptime2 - $inittime) . '秒'; $lasttime = ' 估计还要:' . round(($total - $current) / $speed) . '秒'; $str = $per . '|' .$formatespeed.'|'. $pasttime . $lasttime . '|' . $formatecurrent . '|' . $formatetotal; @file_put_contents('downinfo.txt', $str); $temptime = $temptime2; $initsize = $current; } } $destination_folder = './'; $url = $_POST['url']; $info = get_headers($url, 1); $total = $info['Content-Length']; $current = 0; $newfname = $destination_folder . basename($url); $file = fopen ($url, "rb"); $inittime = $temptime = microtime_float(); $initsize = 0; if ($file) { $newf = fopen ($newfname, "wb"); if ($newf) while (!feof($file)) { $str = fread($file, 1024 * 8); $current += strlen($str); fwrite($newf, $str, 1024 * 8); wrjs(); } echo '下载完毕,共计用时:' . round(microtime_float() - $inittime) . '秒'; } if ($file) { fclose($file); } if ($newf) { fclose($newf); } exit;}if (isset($_GET['getinfo'])) { $arr = file_get_contents('downinfo.txt'); if ($arr) { header("Content-type: text/html; charset=utf-8"); echo $arr; } exit; }?>远程下载*{font-size:12px;}.bar1 {background: url("/images/progress_bar_null.gif"); position:relative; text-align:left; height:13px; width:540px; border:1px solid #505050;margin:0 auto;}.bar2 {background: url("/images/progress_bar.gif"); position:relative; text-align:left; height:13px; width:0%;}.info{width:540px;margin:20px auto;font-size:12px;} [/ol]复制代码图片附件 |
|