APC进度条显示粘性百分比
我在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
刚刚找到答案,我删除了唯一 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.