APC_FETCH() empty during file upload


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.


/* 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();" />

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

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SheppardDigitalAuthor 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.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.