Both html and java script files are on the same page
HTML code corresponding to it is:
<body>
<div id="outer_pog">
<div id="inner_pog">
</div>
</div>
<form action="index.php" method="post" id="myform" enctype="multipart/form-data" target="hidden_frame">
<input type="hidden" value="myform" name="<?php echo ini_get("session.upload_progress.name"); ?>" />
<input type="file" name="userfile" /> <br/>
<input type="submit" value="start upload" />
</form>
<iframe name="hidden_frame" style="display: none;"></iframe>
<span></span>
</body>
javascript code is:
$(function(){
$('#myform').submit(function(e){
$.get('progress.php',function(dt){
$('span').html(dt);
setTimeout(prog,1000);
});
})
});
function prog(){
$.get('progress.php',function(dt){
$('span').html(dt);
if(dt<100)
{
setTimeout(prog,1000);
}
});
}
when I run this i always getting 100 in return,when I debugged it in netbean value of $_SESSION[$key] is always array[0].
php code i.e progress.php , is below:
<?php
session_start();
$key= ini_get("session.upload_progress.prefix")."myform";
if(!empty($_SESSION[$key])){
$cur=$_SESSION[$key]['bytes_processed'];
$tot=$_SESSION[$key]['content_length'];
echo $cur<$tot ? ceil($cur/$tot*100) : 100;
}
else
echo 100;
?>