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 used with php configuration to implement the upload progress bar.
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 used with php configuration to implement the upload progress bar.
Php does not provide the real-time upload progress bar function. If you want to use this function, ajax is usually used. 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 parameters depends on the project's apc. max_file_size: Specifies the size of the files that can be uploaded by apc. apc is required. max_file_size <= upload_max_filesize and apc. 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 ['ss SS _ key']) {$ status = apc_fetch ('upload _'. $ _ GET ['ss SS _ key']); echo ($ status ['stream']/$ 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