进度条在PHP中的编写

<?php
set_time_limit("3600");
ob_end_clean();
for($i = 1;$i <= 300; $i++ ) echo(" ");
$file="jicheng.rar";//你要上传的东东
$obj="upload/website.rar";//目标文件,就是文件上传到哪里
$length="100";//进度条长度,可能不准备
$pimg="pro.gif";//进度条图片
$csize="100000";//每次拷贝的尺寸,单位字节

$size=filesize($file);
if(file_exists($obj)&&is_file($obj)){
   $fsize=filesize($obj);
}
else{
   $fsize="0";
}
$data=fread(fopen("$file","rb"),$size);
$nums=ceil(($size-$fsize)/$csize);
echo"<img src=$pimg width=".floor($length*$fsize/$size)." height=10>";
for($i="0";$i<$nums;$i++){
   $start=$fsize+$i*$csize;
   $cdata=substr($data,$start,$csize);
   $msize=strlen($cdata);
   fwrite(fopen($obj,"ab"),$cdata);
   echo"<img src=$pimg width=".floor($length*$msize/$size)." height=10>";
   flush();
   sleep(1);
}
echo"上传成功";
?> 

随机日志

发表评论

0 评论.

Leave a Reply



[ Ctrl + Enter ]

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word

CNXCT小组的博客 is Stephen Fry proof thanks to caching by WP Super Cache