APCÄ£¿e£¬ËuµÄÈ«³ÆÊÇAlternative PHP Cache¡£APC¿ÉÒÔ½«ËuÓÐPHP´uÂe»a±»»º´aeÆðÀ´£¬ ÁiÍaËu¿ÉÌa¹(C)Ò»¶¨µÄÄÚ´ae»º´ae¹¦ÄÜ.µ«ÊÇÕa¸o¹¦Äܲ¢²»ÊÇÊ®ÖÍeÃÀ,Óб¨¸ae˵Èç¹uƵ±Ê¹ÓÃAPC»º´aeµÄдÈe¹¦ÄÜ,»aµ¼Ö²»¿ÉÔ¤ÁϵĴiÎo.Èç¹uÏeʹÓÃÕa¸o¹¦ÄÜ£¬¿ÉÒÔ¿´¿´apc_fetch,apc_storeµÈ¼¸¸oÓeapc»º´aeÏa¹ØµÄº¯Êý¡£
ÖµµÃ¸ßÐ˵ÄÊÇ´Ó5.2¿ªÊ¼APC¼ÓÈeÁËAPC_UPLOAD_PROGRESS£¬½a¾oÁËÀ§ÈÅ´o¼ÒÒѾõĽø¶ÈÌoÎÊÌa¡£²¢ÇÒËu°ÑÔÀ´µÄÉÏ´«Ê±°ÑÁÙʱÎļþÈ«²¿»º´aeµ½ÄÚ´ae¸Ä³ÉÁ˵±ÁÙʱÎļþ´iµ½Ée¶¨ÖµÊ±¾Í×Ô¶¯±£´aeµ½Ó²ÅÌ£¬ÓÐЧµØ¸ÄÉÆÁËÄÚ´aeÀuÓÃ×´¿o¡£
ËuµÄ×÷ÓÃÔÀiÊÇÔÚÉÏ´«Ê±ºo¸³Óeÿ¸oÉÏ´«Ò»¸oΨһµÄID£¬µ±PHP ½Å±¾ÊÕµ½Ò»¸oÉÏ´«Îļþʱ£¬½aÊͳÌÐo½«×Ô¶¯¼i²e$_POSTÊý×eÖÐÃuΪAPC_UPLOAD_PROGRESS µÄÒþ²Ø×ֶΣ¬Ëu½«³ÉΪ»º´ae±aÁ¿£¬´ae´¢¹ØÓÚÉÏ´«µÄÐÅÏ¢£¬ÕaÑu½Å±¾¾Í¿ÉÒÔͨ¹ýÉÏ´«µÄIDÀ´*ÃÎÊÉÏ´«ÎļþµÄ״̬ÐÅÏ¢¡£
<!¨CÒÔÏÂΪÉÏ´«±iµ¥¨C>
<form enctype="multipart/form-data" id="upload_form" action="" method="POST">
<input type="hidden" name="APC_UPLOAD_PROGRESS" id="progress_key" value="upid"/>
ÊÓƵ±eÌa£º<input type="text" id="subject" name="subject"/>
ÊÓƵ˵Ã÷£º<input type="text" id="content" name="content"/>
ÊÓƵTAG(ÒÔ¶ººÅ*Ö¸i)<input type="text" id="tag" name="tags"/>
<input type="file" id="upfile" name="upfile"/>
<input type="submit" id="filesubmit" value="ÉÏ´«" onclick="startProgress(¡®upid'); return true;"/>
<!¨C×¢Òa:startProgress(¡®upid')ÖеIJÎÊýÊÇÄa´ÓphpÖÐ*ÖÅaµÄΨһÉÏ´«²ÎÊý¨C>
</form>
<!¨CÒÔÏÂΪÉÏ´«½ø¶ÈÌo¨C>
<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>
×iÖ÷ÒªµÄ¾ÍÊÇÄǸoAPC_UPLOAD_PROGRESSµÄÒþ²ØÓo£¬ÓÐÁËËu½Å±¾²ÅÄÜÈ¥*ÃÎÊÄ¿Ç°ÉÏ´«ÎļþµÄ״̬£¬ÁiÍa¼ÓÒ»¸oÏÔʾÉÏ´«×´Ì¬µÄdiv¾ÍºÃÁË¡£
ÏÂÃaeÊÇ´¦ÀiAjaxµÄ½Å±¾£¬ÓÃÁËJquery¿o¼Ü£¬json´«µÝÏuÏ¢¡£
function getProgress(upid){
var url = "<{$siteurl}>epadmin/upprocess";
$.getJSON(
url,
{ progress_key: upid },
function(json){
$("#progressinner").width(json.per+"%");
$("#upstatus").html(¡®Îļþ´oС:'+json.total+¡®KB'+¡® ÒÑÉÏ´«:'+json.current+¡®KB');
if (json.per < 100){
setTimeout(function(){
getProgress(upid);
}, 10);
}else{
$("#upstatus").html("ÊÓƵÉÏ´«Íe³É£¬ÕýÔÚ´¦ÀiÊý¾Ý£¬ÇeÉÔºo¡¡");
}
}
)
}
function startProgress(upid){
$("#progressouter").css({ display:"block" });
setTimeout(function(){
getProgress(upid);
}, 100);
}
ÔÙÏÂÀ´¾ÍÊǶÁÈ¡ÉÏ´«×´Ì¬µÄPHP´uÂeÁË£¬ÖÁÓÚÉÏ´«ÎļþµÄ´¦Ài¿ÉÒÔ°´ÕÕƽ³£×Ô¼ºµÄÀ´Ð´¡£
//ÉÏ´«Îļþ²Ù×÷º¯Êý£¬¿É°´ÕÕ×Ô¼ºµÄÐeÒª±aд
function upflvAction()
{
if($_SERVER['REQUEST_METHOD']==¡®POST'){
$subject = trim($this->f->filter($this->_request->getPost(¡®subject')));
$content = trim($this->f->filter($this->_request->getPost(¡®content')));
Zend_Loader::loadClass(¡®Custom_FlvOp');
$flv = new Custom_FlvOp;
$flv->uploadFlv(¡®upfile',$subject,$content);
}
}
//Õa¾ÍÊǶÁÈ¡ÉÏ´«×´Ì¬µÄº¯ÊýÁË~~
function upprocessAction()
{
if(isset($_GET['progress_key'])) {
$status = apc_fetch(¡®upload_'.$_GET['progress_key']);
$json = array(
¡®per'=>$status['current']/$status['total']*100,
¡®total'=>round($status['total']/1024),
¡®current'=>round($status['current']/1024),
);
require_once("Zend/Json.php");
echo Zend_Json::encode($json);
}
}
ºÃÁË£¬ÏÖÔھͿÉÒÔ½«Æa²¿Êð×Ô¼ºµÄÕ¾µaÖÐÁË£¬×Ô¼º¿´¿´Ð§¹uÊDz»ÊǺܿa£¿
ÒÔÉϾÍÊÇPHPµÄAPCÄ£¿eÖÆ×÷ÉÏ´«½ø¶ÈÌoµÄ¹Ø¼uµa½eÉÜ£¬Ï£Íu¶Ô´o¼ÒµÄѧϰÓÐËuÆo*¢£¬¶Ô´o¼ÒÓÐËu°iÖu¡£