APC_FETCH() empty during file upload

Hi,

I'm trying to create  a file upload progress bar using PHP and the APC_FETCH function.

I've had APC enabled on the server and set to On. I've downloaded a sample script, which works perfectly, however, while building my own, APC_FETCH() isn't returning a status for the file.

I am generating a unique ID, which is being set as the progress_key in the form. I'm then having an iframe populated with the content on a progress page with the progress_key also being passed to the progress page so it can get it's status. But there are no results.

Does anyone have any idea where I'm going wrong, as other scripts work perfectly, just not my own.

Thanks


/* THE FORM */
<?php $upid = uniqid(); ?>
<form id="form1" name="form1" enctype="multipart/form-data" method="post" action="">
  <input type="file" name="fileField" id="fileField" />
  <input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $upid; ?>"/>
  <input type="submit" name="button" id="button" value="Submit" onclick="startUpload();" />
</form>

/* THE STATUS PAGE */
<?php
if(isset($_GET['upid'])) {
	echo rand();
	echo "<br>upid = ".$_GET['upid'];
	$status = apc_fetch('upload_'.$_GET['upid']);
	echo $status['current']/$status['total']*100;
	die;
	}
?>

Open in new window

SheppardDigitalAsked:
Who is Participating?
 
SheppardDigitalConnect With a Mentor Author Commented:
I came across a comment on an internet message board which the
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $upid; ?>"/>
needs to be before the file fields.

I moved it and this resolved the issue.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.