实现效果:
准备工作:
1、参考IBM的PHP V5.2 中的新增功能,第 5 部分: 跟踪文件上传进度,以下是链接地址:http://www.ibm.com/developerworks/cn/opensource/os-php-v525/
2、下载php_apc.dll。在网上很容易搜到php_apc.dll的下载地址。
extension=php_apc.dll
;apc.enabled = 1
;apc.shm_segments = 1
;apc.shm_size = 64
;apc.optimization = 0
;apc.num_files_hint = 1000
;apc.ttl = 0
;apc.gc_ttl = 3600
;apc.cache_by_default = On
;apc.slam_defense = 0
;apc.file_update_protection = 2
;apc.enable_cli = 0
;apc.stat=0
apc.rfc1867=1
apc.max_file_size = 100M
upload_max_filesize = 100M
post_max_size = 100M
3、因为实现提交和显示进度条用到jQuery的内容,上传文件也采用了jQuery的弹出对话框的方式,所以,要下载jQuery的核心文件和UI文件。
页面组成
1、lwjUpload1.php
2、lwjfileUp.php
3、getProgress.php
程序实现
lwjUpload1.php
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>李婉佳的文件上传进度条</title>
<link type="text/css" href="css/jquery.ui.all.css"rel="stylesheet" />
<link type="text/css" href="css/demos.css"rel="stylesheet" />
<script type="text/javascript"src="scripts/jquery-1.4.3.js"></script>
<script type="text/javascript"src="scripts/jquery.ui.core.js"></script>
<script type="text/javascript"src="scripts/jquery.bgiframe-2.1.1.js"></script>
<script type="text/javascript"src="scripts/jquery.ui.widget.js"></script>
<script type="text/javascript"src="scripts/jquery.ui.mouse.js"></script>
<script type="text/javascript"src="scripts/jquery.ui.draggable.js"></script>
<script type="text/javascript"src="scripts/jquery.ui.position.js"></script>
<script type="text/javascript"src="scripts/jquery.ui.resizable.js"></script>
<script type="text/javascript"src="scripts/jquery.ui.dialog.js"></script>
<script type="text/javascript"src="scripts/jquery.effects.core.js"></script>
<script type="text/javascript"src="scripts/jquery.effects.highlight.js"></script>
<script type="text/javascript"src="scripts/jquery.effects.scale.js"></script>
<script type="text/javascript"src="scripts/jquery.effects.blind.js"></script>
<script type="text/javascript"src="scripts/jquery.effects.explode.js"></script>
<script type="text/javascript"src="scripts/jquery.form.js"></script>
<style type="text/css">
*
{
margin:0;
padding:0;
}
input,label
{
margin-top:10px;
}
#fileUpload
{
width:20em;
height:2em;
}
a.aButton
{
font-size:1.2em;
color:black;
}
a.aButton:hover
{
color:#0066CC;
text-decoration:none;
}
</style>
<scripttype="text/javascript">
//初始化对话框,让对话框隐藏,不自动弹出,并设置对话框关闭的速度(速率)
$.fx.speeds._default= 500; //对话框显示和隐藏的速度
$(function(){
});
//弹出文件上传的对话框
var uid;
function dialogOpen()
{
}
//设置ajaxSubmit的参数
var options = {
};
functionshowResponse(responseText,statusText){
}
function getProgress()
{
}
functiongetStatus(responseText,statusText)
{
}
function ajaSub()
{
}
</script>
</head>
<body>
//这一段用来检查apc是否可用
if (function_exists('apc_fetch')) {
echo 'it surpport apc model!';
} else {
}
?>
</body>
</html>
lwjfileUp.php
<?php
?>
getProgress.php
<?php
if(isset($_GET['progress_key'])) {
}
?>