php apc division by zero error
<p>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.</p>

<pre><code>http://www.johnboy.com/php-upload-progress-bar/
</code></pre>

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

<pre><code>http://way2enjoy.com/modules/music/try/try/upload.php
</code></pre>

<p>everything seems to be correct but the progress bar in my case shows NaN%</p>

<p>i checked the error log which shows this error</p>

<pre><code> [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
</code></pre>

<p>my code of upload_frame.php is</p>

<pre><code>&lt;?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;
}

?&gt;

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

&lt;script&gt;
$(document).ready(function() { 


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

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


&lt;/script&gt;

&lt;body style="margin:0px"&gt;
&lt;div id="progress_container"&gt;
&lt;div id="progress_bar"&gt;
     &lt;div id="progress_completed"&gt;&lt;/div&gt;


&lt;/div&gt;
&lt;/div&gt;
 &lt;/body&gt;
</code></pre>

<p>upload.php code</p>

<pre><code>&lt;?php 
$up_id = uniqid(); 
?&gt;

&lt;?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;
}

?&gt;

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

&lt;link href="http://way2enjoy.com/files/common_css/style_progress.css" rel="stylesheet" type="text/css" /&gt;

&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.js" type="text/javascript"&gt;&lt;/script&gt;

&lt;script&gt;

$(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=&lt;?php echo $up_id; ?&gt;');
        }
        setTimeout(set);
    }
});

});

&lt;/script&gt;

&lt;/head&gt;

&lt;body&gt;
&lt;h1&gt;Upload your file &lt;/h1&gt;

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

&lt;br /&gt;
Choose a file to upload&lt;br /&gt;

&lt;input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="&lt;?php echo $up_id; ?&gt;"/&gt;

&lt;input name="file" type="file" id="file" size="30"/&gt;

&lt;br /&gt;
&lt;iframe id="upload_frame" name="upload_frame" frameborder="0" border="0" src="" scrolling="no" scrollbar="no" &gt; &lt;/iframe&gt;
&lt;br /&gt;

&lt;input name="Submit" type="submit" id="submit" value="Submit" /&gt;
</code></pre>

<p>
  </p>

<p></p>

<p></p>

<p>my php configuration for APC</p>

<pre><code>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
</code></pre>
