帖子更新:根据评论者的建议。
Index.php
<?php
$id = uniqid("");
?>
</head>
<body>
<form method="post" action="frame.php" target="upload_iframe" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $id; ?>"/>
<br />
<input type="submit" name="submit" value="Submit" />
</form>
<iframe name="upload_iframe" style="width: 400px; height: 100px;">
</iframe>
frame.php
<?php
if(isset($_POST['progress_key'])) {
echo "hey1";
$status = apc_fetch('upload_'.$_POST['progress_key']);
echo $status['current']/$status['total']*100;
}
echo "hey2";
?>
仍然不起作用:(,我什至没有在框架中获取 POST 表单数据。我哪里错了?
问候。
Post Updated: After commentors advice.
Index.php
<?php
$id = uniqid("");
?>
</head>
<body>
<form method="post" action="frame.php" target="upload_iframe" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo $id; ?>"/>
<br />
<input type="submit" name="submit" value="Submit" />
</form>
<iframe name="upload_iframe" style="width: 400px; height: 100px;">
</iframe>
frame.php
<?php
if(isset($_POST['progress_key'])) {
echo "hey1";
$status = apc_fetch('upload_'.$_POST['progress_key']);
echo $status['current']/$status['total']*100;
}
echo "hey2";
?>
Still doesnt work :(, I dont even get POST form data in frame. Where am i going so wrong?
Regards.
发布评论
评论(1)
每当您使用 APC 文件上传机制时,您都需要向表单添加一个附加参数,用于标识正在上传的文件,并且是
apc_fetch
的键。当文件上传时,密钥中的值
上传 . $id
将包含显示进度条所需的信息。最简单的方法是使用 apc_fetch 调用 ajax 轮询服务器。这表明您的上传页面不需要刷新用户所在的当前页面。我过去使用过iframe
来启动轮询服务器的间隔。上传完成后,您可以在同一 iframe 中显示完整的消息。Whenever you use the APC file upload mechanism, you need to add an additional parameter to your form that identifies the file that's being uploaded, and is the key for your
apc_fetch
.<?php $id = uniqid(time()); ?>
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="myUniProgressKey" value="<?php echo $id; ?>"/>
As the file is uploaded the value in the key
upload . $id
will contain the info you need to display the progress bar. Easiest way to get to is to ajax poll the server, using theapc_fetch
call you have. This dictates that your upload page needs to not refresh the current page the user is on. I've used aniframe
in the past that kicks off an interval to poll the server. Once the upload is complete, you're able to show a nice complete message in the same iframe.绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
关于作者
暂无简介
相关话题
热门标签
推荐作者
胡图图
文章 0 评论 0
zt006
文章 0 评论 0
z祗昰~
文章 0 评论 0
冰葑
文章 0 评论 0
野の
文章 0 评论 0
天空
文章 0 评论 0
友情链接
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。