I encountered a problem when I wanted to show a process bar in a file upload.
My php version is 5.3.14. My zend server version is 5.6. I turned off the Zend Data Cache & Zend Optimizer+.
Here is my upload code.
<?php
$uiq = uniqid();
$image_folder = "uploads/";
$uploaded = false;
if(isset($_POST['upload_image'])){
if($_FILES['userImage']['error'] == 0 ){
$up = move_uploaded_file($_FILES['userImage']['tmp_name'], $image_folder.$_FILES['userImage']['name']);
if($up){
$uploaded = true;
}
}
}
?>
Following is my process code called by ajax.
if(isset($_GET['progress_key']) and !empty($_GET['progress_key'])){
$status = apc_fetch('upload_'.$_GET['progress_key']);
if($status){
echo $status['current']/$status['total']*100;
}else{
echo 0;
}
exit;
}
The apc_fetch
function always return false. Does anyone know the reason?