您好,登錄后才能下訂單哦!
<?php
/*
@desc:php下載文件顯示進(jìn)度
@param file 待下載文件名
@param name 存儲(chǔ)到本地文件名
*/
function downloadprogress($file,$name){
$dir = dirname($name);
if(!is_dir($dir)){
mkdir($dir,0755,true);
}
ob_start();
set_time_limit(0);
$fr = fopen ($file, "rb");
if ($fr) {
$content = file_get_contents($file);
$filesize = strlen($content);
$fw = fopen ($name, "wb");
$downlen=0;
$last = 0;
$diff = 0;
echo "[";
if ($fw) {
while(!feof($fr)) {
$data = fread($fr, 1024 * 8 );
$downlen += strlen($data);
fwrite($fw, $data, 1024 * 8 );
$percent = round($downlen/$filesize*100,2);
$diff += $percent - $last;
if($diff > 1){
echo "#";
$diff = 0;
}
$last = $percent;
ob_flush();
flush();
}
echo "#]done";
}
if ($fr) {
fclose($fr);
}
if ($fw) {
fclose($fw);
}
}
}
downloadprogress('2018.rar','aaa/01.rar');
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。