php/apc 监控文件上传进度
2010-05-10 14:04
549 查看
原文地址: http://blog.csdn.net/lmss82/archive/2010/05/10/5574772.aspx
这是一个完整可用的代码,部分代码来自于网络。
PHP:
5.26
JS环境:
jquery.js,jquery_form.js
使用步骤:
开启APC.
下载php_apc.dll,修改php.ini文件增加以下内容:
extension=php_apc.dll
apc.rfc1867 = On
代码:
这是一个完整可用的代码,部分代码来自于网络。
PHP:
5.26
JS环境:
jquery.js,jquery_form.js
使用步骤:
开启APC.
下载php_apc.dll,修改php.ini文件增加以下内容:
extension=php_apc.dll
apc.rfc1867 = On
代码:
<?php //<BS>X_REQUESTED_WITH /* 上传文件 */ if(isset($_FILES['upfile'])){ $uploaddir = $_SERVER['DOCUMENT_ROOT']."/uploadprogress/upfile/"; $uploaddir.= date("YmdHis",time()).'_'.$_FILES['upfile']['name']; if(move_uploaded_file($_FILES["upfile"]["tmp_name"], $uploaddir)) { echo "上传成功!"; exit; } } /* 获取上传进度信息 */ if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'){ if(isset($_GET['APC_UPLOAD_PROGRESS']) && $_GET['do'] == 'retrieving') { $status = apc_fetch('upload_'.$_GET['APC_UPLOAD_PROGRESS']); if($status['total']!=0 && !empty($status['total'])) { $json = array( 'per'=> $status['current']/$status['total']*100, 'total'=> round($status['total']/1024), 'current'=> round($status['current']/1024), ); echo json_encode($json); exit; } else { echo (0); exit; } } } ?> <mce:script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" mce_src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"><!-- </script > <script type="text/javascript" src="jquery.form.js" mce_src="jquery.form.js"></script > <script type="text/javascript"> $(document).ready(function() { // This is more like it! $('#upload_form').ajaxForm(function() { //alert("Thank you for your comment!"); }); }); // --></mce:script> <mce:script type="text/javascript" ><!-- function getProgress(upid){ var url = "index.php"; $.getJSON( url, { APC_UPLOAD_PROGRESS: upid,do:'retrieving'}, function(json){ $("#progressinner").width(json.per+"%"); $("#progressinner").html(parseInt(json.per)+"%"); $("#upstatus").html('文件大小:'+json.total+'KB'+' 已上传:'+json.current+'KB'); if (json.per < 100){ setTimeout(function(){ getProgress(upid); }, 10); }else{ $("#upstatus").html("文件上传完成"); $("#progressouter").hide("slow"); } } ) } function startProgress(){ var upid = $("#progress_key").val(); $("#progressinner").html("0%"); $("#progressinner").width("0%"); $("#progressouter").show(); setTimeout(function(){ getProgress(upid); }, 100); } // --></mce:script> <form enctype="multipart/form-data" id="upload_form" action="index.php" method="POST"> <input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="<?php echo uniqid(mt_srand())?>"/> <input type="file" id="upfile" name="upfile"/><br/><br/> <input type="submit" id="filesubmit" value="上传" onclick="startProgress();"/> </form> <div id="upstatus" style="width: 500px; height: 30px; border: 1px solid #ffffde; color:#796140;"> </div <div id="progressouter" style="width:500px;height:20px;border:3px solid #de7e00;display:none;"> <div id="progressinner" style="position:relative;height:20px;color:#796140;background-color:#f6d095;width: 0%;"> </div> </div>
相关文章推荐
- PHP文件上传进度条完整程序实现 jQuery Ajax apc
- PHP使用APC获取上传文件进度
- PHP使用APC获取上传文件进度
- php apc上传文件带进度
- PHP通过APC获取上传文件进度
- html表单结合php实现上传文件功能并且监控文件上传的进度
- Android使用HttpClient实现文件上传到PHP服务器,并监控进度条
- 使用 APC 为 php 5.2.0 文件上传实现进度条
- Android使用HttpClient实现文件上传到PHP服务器,并监控进度条
- PHP 大文件上传进度条实现
- PHP+apc+ajax实现的ajax_upload上传进度条代码
- 给LNMP PHP安装APC 以便支持上传进度条功能
- php实现文件上传进度条
- PHP中使用Session配合Javascript实现文件上传进度条功能
- Ajax+php带进度条上传文件
- PHP+Ajax实现上传文件进度条动态显示进度功能
- PHP文件上传进度处理方法
- PHP利用apc实现上传进度条方法
- PHP5.2 跟踪文件上传进度[来自IBM]
- PHP:显示文件上传进度及上传任意大小的文件