dos8244 2012-06-24 04:12
浏览 56
已采纳

php apc除以零错误

i am using APC(php) to show the progress bar but i am stuck at one point . i have used this link and everything is write and APC is installed as well.

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

i have used the same code with little modified path to store the images my link is

http://way2enjoy.com/modules/music/try/try/upload.php

everything seems to be correct but the progress bar in my case shows NaN%

i checked the error log which shows this error

 [23-Jun-2012 20:20:26 UTC] PHP Warning:  Division by zero in /home/XXXXXXX/public_html/modules/music/try/try/upload_frame.php on line7

my code of upload_frame.php is

<?php

$url = basename($_SERVER['SCRIPT_FILENAME']);

if(isset($_GET['progress_key'])) {
$status = apc_fetch('upload_'.$_GET['progress_key']);
    echo $status['current']/$status['total']*100;

die;
}

?>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js"    type="text/javascript"></script>
<link href="style_progress.css" rel="stylesheet" type="text/css" />

<script>
$(document).ready(function() { 


setInterval(function() 
    {
$.get("<?php echo $url; ?>?progress_key=<?php echo $_GET['up_id']; ?>&randval="+ Math.random(), { 

},
    function(data)
        {
            $('#progress_container').fadeIn(100);   
            $('#progress_bar').width(data +"%");    
            $('#progress_completed').html(parseInt(data) +"%"); 
        }
    )},500);    
});


</script>

<body style="margin:0px">
<div id="progress_container">
<div id="progress_bar">
     <div id="progress_completed"></div>


</div>
</div>
 </body>

upload.php code

<?php 
$up_id = uniqid(); 
?>

<?php

if ($_POST) {

$folder = "tmp/"; 
$folder1 = "/home/XXXXXX/public_html/modules/music/try/try/"; 
$redirect = "upload.php?success";

move_uploaded_file($_FILES["file"]["tmp_name"], "$folder1" . $_FILES["file"]["name"]);


header('Location: '.$redirect); die;
}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0    Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Upload your file</title>

<link href="http://way2enjoy.com/files/common_css/style_progress.css" rel="stylesheet" type="text/css" />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js" type="text/javascript"></script>

<script>

$(document).ready(function() { 


var show_bar = 0;
$('input[type="file"]').click(function(){
    show_bar = 1;
});

$("#form1").submit(function(){

    if (show_bar === 1) { 
        $('#upload_frame').show();
        function set () {
            $('#upload_frame').attr('src','upload_frame.php?up_id=<?php echo $up_id; ?>');
        }
        setTimeout(set);
    }
});

});

</script>

</head>

<body>
<h1>Upload your file </h1>

<div>
 <?php if (isset($_GET['success'])) { ?>
 <span class="notice">Your file has been uploaded.</span>
 <?php } ?>
 <form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">

<br />
Choose a file to upload<br />

<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $up_id; ?>"/>

<input name="file" type="file" id="file" size="30"/>

<br />
<iframe id="upload_frame" name="upload_frame" frameborder="0" border="0" src="" scrolling="no" scrollbar="no" > </iframe>
<br />

<input name="Submit" type="submit" id="submit" value="Submit" />

my php configuration for APC

apc.cache_by_default    On  On
apc.canonicalize    On  On
apc.coredump_unmap  Off Off
apc.enable_cli  Off Off
apc.enabled On  On
apc.file_md5    Off Off
apc.file_update_protection  2   2
apc.filters no value    no value
apc.gc_ttl  3600    3600
apc.include_once_override   Off Off
apc.lazy_classes    Off Off
apc.lazy_functions  Off Off
apc.max_file_size   1M  1M
apc.mmap_file_mask  no value    no value
apc.num_files_hint  1000    1000
apc.preload_path    no value    no value
apc.report_autofilter   Off Off
apc.rfc1867 On  On
apc.rfc1867_freq    0   0
apc.rfc1867_name    APC_UPLOAD_PROGRESS APC_UPLOAD_PROGRESS
apc.rfc1867_prefix  upload_ upload_
apc.rfc1867_ttl 3600    3600
apc.serializer  default default
apc.shm_segments    1   1
apc.shm_size    32M 32M
apc.slam_defense    On  On
apc.stat    On  On
apc.stat_ctime  Off Off
apc.ttl 0   0
apc.use_request_time    On  On
apc.user_entries_hint   4096    4096
apc.user_ttl    0   0
apc.write_lock  On  On
  • 写回答

2条回答 默认 最新

  • douwen7331 2013-06-22 18:56
    关注

    Did you read the IMPORTANT note from the project's page :

    Important: Make sure to include apc.rfc1867 = on in your php.ini

    It worked for me.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型