Business requirements to get the progress of uploading a post file, usually PHP scripts to be executed after the post upload file is completed, so there is no way to get the upload speed directly within the script, not as the execution time, and then the end of the <?php at the beginning of a time and then add time to subtract.
The first way to think of this is through Ajax, before uploading a request to the server to record the current time, and then post the file.
Of course, this is not the solution, only to know the file upload start of the approximate time, and the end time, the progress is not known.
Check it out online:
Http://www.cnblogs.com/yjf512/p/3173457.html
Http://www.laruence.com/2011/10/10/2217.html
There are two ways, one is more than 5.2 APC, and the other is the PHP5.4 session mechanism. Because the session mechanism requires 5.4, so still choose APC Bar, APC ready to be integrated into PHP, this thing is very useful!
PHP Manual Description: http://cn2.php.net/manual/en/apc.configuration.php#ini.apc.rfc1867
APC first to determine the configuration
Apc.rfc1867=on
Then the form:
[HTML]View Plaincopyprint?
- <form enctype="Multipart/form-data" action="up4.php" method="POST">
- <input type="hidden" name="apc_upload_progress" value="abc"/>
- Send This file: <input name= "userfile" type="file" />
- <input type="Submit" value= "Send File" />
- </form>
Forms note the hidden fields of apc_upload_progress must precede the file field
And then the PHP file that queries the progress.
[PHP]View Plaincopyprint?
- <?php
- Print_r (Apc_fetch ("UPLOAD_ABC"));
When you upload it, you can see the upload progress by executing the query file.
PS: Add, usually this skill can only be the query upload progress, the role is not small. However, when the sequence of uploading fragmented files in the case, the PHP side to know the shards being uploaded (it is convenient to tell the client what the next piece), then it seems more meaningful.
PHP gets upload file progress via APC