This article describes how to use APC to implement the real-time Upload progress bar function in php. php does not provide the real-time Upload progress bar function, but php provides an apc, it can be configured with php to implement the upload progress bar. if you are interested, you can refer to the fact that php does not have the real-time Upload progress bar function. if you want this function, we generally use ajax to implement it, however, php provides an apc, which can be configured with php to implement the upload progress bar function.
It mainly targets applications on Windows.
1. the server must support apc extension. if this extension is not available, download php.5.2 or above for an extension.
2. configure apc and restart apache.
The code is as follows:
Extension = php_apc.dll
Apc. rfc1867 = on
Apc. max_file_size = 1000 M
Upload_max_filesize = 1000 M
Post_max_size = 1000 M
Note: the size of the parameters depends on the apc. max_file_size required for the project and the size of the files supported by apc.Apc. max_file_size <= upload_max_filesizeAndApc. max_file_size <= post_max_size.Restart apache to support apc.
3. use phpinfo () in the code to check whether the apc extension is installed.
4. The following is the implementation code:
Getprogress. php
The code is as follows:
<?php session_start(); if(isset($_GET['progress_key'])) { $status = apc_fetch('upload_'.$_GET['progress_key']); echo ($status['current']/$status['total'])*100; } ?> upload.phpPHP Code<?php $id = $_GET['id']; ?>
Target. php
The code is as follows:
<? 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"]); // The UploadTemp folder is located in echo under the same directory of the script"Uploaded
";}?>
Index. php
The code is as follows:
<? Php $ id = md5 (uniqid (rand (), true);?> Upload progress