开发者

APC progress bar show sticky percentage

I have problem using APC progress bar I follow from this example

http://www.johnboy.com/php-upload-progress-bar/

I modified the code and it works. The problem is it will display the last percentages after I refresh the page. Let say a file is just finish uploaded at 100%, it will display 100% after I refresh the page. If I cancel halfway when the file being uploaded, say at 15%, 15% will stick on the progress bar until I upload another file.

Here is potion of my codes:

if(isset($_GET['progress_key'])) {
  $upload = apc_fetch('upload_1234'.$_POST['APC_UPLOAD_PROGRESS']);
    if开发者_如何学运维 ($upload) {
      if ($upload['done']) {
      echo $percent = 100;
    }
    else if ($upload['total'] == 0) {
      echo $percent = 0;
    }
    else {
      echo $percent = $upload['current'] / $upload['total'] * 100;
    }
  }
  die;
}

Thank you in advance.


just found the answer, I remove the unique id and replace with upload_1234 so the apps cannot differentiate the upload process.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜