APC进度条显示粘性百分比

发布于 2024-08-19 14:53:39 字数 716 浏览 2 评论 0原文

我在使用 APC 进度条时遇到问题,我按照此示例进行操作
http://www.johnboy.com/php-upload-progress-bar/< /a>

我修改了代码并且它有效。问题是刷新页面后它会显示最后的百分比。假设一个文件刚刚上传到100%,刷新页面后就会显示100%。如果我在上传文件时中途取消,比如在 15% 时,进度条上会一直显示 15%,直到我上传另一个文件。

这是我的代码的一部分:

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;
}

提前谢谢您。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

轻拂→两袖风尘 2024-08-26 14:53:39

刚刚找到答案,我删除了唯一 ID 并替换为 upload_1234,以便应用程序无法区分上传过程。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文