Hello,
I am attempting to create a file upload status indicator via a popup box(possibly a iframe if I can get it working right) and minimal javascript. I am hoping someone can offer some advice as to why it is not working.
I am using APC_UPLOAD_PROGRESS (yes, APC is installed and working) in the form and I am sending the id to the popup window but the popup will not show the status of the upload. apc_fetch returns nothing. I can however see the status in the main window once the file upload is complete in the main page. Is it possible to see apc_fetch in another window?
I hope all this makes sense. Here is the source code...
First The Page With The Form
<?
$upload_id=uniqid();
?>
<form enctype='multipart/form-data' id='upload_form' action='upload_test_new.php' onSubmit="window.open('file_upload.php?pk=<?php echo $upload_id?>' ,'', 'top=75, left=75, width=500, height=225, scrollbars')" method='POST'>
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $upload_id?>"/>
<input type="file" id="test_file" name="userfile"/><br/>
<input type='hidden' name='go' value='upload' />
<input type='hidden' name='pk' value='<?php echo $upload_id?>' />
<input type="submit" value="Upload!"/>
</form>
<?
if($go=='upload')
{
$fileName = $_FILES['userfile']['name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$tempfile = $_FILES['userfile']['tmp_name'];
echo"File Type: $fileType<br>File Name: $fileName<br>File Size: $fileSize<br>Temp File: $tempfile";
$pk="upload_$pk";
$status = apc_fetch("$pk");
echo json_encode($status);
echo"<br>PK:$pk";
}
?>
Now The page To Display The Status
<head>
<meta http-equiv="refresh" content="1" />
</head>
<body>
<?php
$pk="upload_$pk";
$status = apc_fetch("$pk");
echo $status;
echo json_encode($status);
echo" - $pk";
?>
</body>
All this code is very raw right now.
Thanks for any suggestions!