The main target is the application on window.
1. The server to support APC expansion, without this extension, Baidu click Php_apc.dll, download an extension of expansion requirements php.5.2 above.
2. Configure APC configuration, restart Apache
The code is as follows |
Copy Code |
Extension=php_apc.dll apc.rfc1867 = On Apc.max_file_size = 1000M Upload_max_filesize = 1000M Post_max_size = 1000M
|
Explain: As for the parameters to match how big, need to see the project needs apc.max_file_size, set up APC support upload file size, request Apc.max_file_size <=upload_max_filesize and Apc.max_ File_size <=post_max_size. You can implement APC support by restarting Apache.
3. Use Phpinfo () in the code to see if the APC extension is installed.
4. Here is the implementation code:
getprogress.php
The code is as follows |
Copy Code |
<?php Session_Start (); if (Isset ($_get[' Progress_key ')) { $status = Apc_fetch (' upload_ '. $_get[' Progress_key ')); Echo ($status [']/$status [' Total ']) *100; } ?> upload.php PHP Code <?php $id = $_get[' id ']; ?> <form enctype= "Multipart/form-data" id= "Upload_form" action= "target.php" method= "POST" > <input type= "hidden" name= "apc_upload_progress" Id= "Progress_key" value= "<?php echo $id?>"/> <input type= "File" id= "Test_file" name= "Test_file"/><br/> <input onclick= "window.parent.startProgress (); return true; " Type= "Submit" value= "Upload"/> </form> |
target.php
The code is as follows |
Copy Code |
<?php Set_time_limit (600); if ($_server[' Request_method ']== ' POST ') { Move_uploaded_file ($_files["Test_file"] ["Tmp_name"], DirName ($_server[' script_filename '). " /uploadtemp/". $_files["Test_file" ["name"]);//uploadtemp folder is located in the same directory as this script echo "<p> upload success </p>"; } ?>
|
index.php
The code is as follows |
Copy Code |
<?php $id = MD5 (Uniqid (rand (), true); ?> <body> <script src= "Js/jquery-1.4.4.min.js" language= "JavaScript" ></script>
<script language= "JavaScript" > var pronum=0; var loop=0; var Progressresult; function Sendurl () { $.ajax ({ Type: ' Get ', URL: "getprogress.php?progress_key=<?php echo $id;? > ", Async:true, Cache:false, DataType: ' JSON ', Data: "progress_key=<?php echo $id;? > ", Success:function (e) { Progressresult = e; Pronum=parseint (Progressresult); document.getElementById ("Progressinner"). Style.width = pronum+ "%"; document.getElementById ("Shownum"). InnerHTML = pronum+ "%"; if (Pronum < 100) { SetTimeout ("getprogress ()", 100); }
} });
}
function getprogress () { loop++;
Sendurl (); } var interval; function startprogress () { document.getElementById ("Progressouter"). style.display= "Block"; SetTimeout ("getprogress ()", 100); } </script> <iframe id= "Theframe" name= "Theframe" Src= "upload.php?id=<?php echo $id;?>" Style= "Border:none; height:100px; width:400px; "> </iframe> <br/><br/> <div id= "Progressouter" style= "width:500px; height:20px; BORDER:6PX solid red; Display:none; " > <div id= "Progressinner" style= "position:relative; height:20px; Background-color:purple; width:0%; "></div> </div> <div id= ' Shownum ' ></div><br> <div id= ' showNum2 ' ></div> </body> |