📜 ⬆️ ⬇️

File Upload File Download Rate (Upload Progress Meter)

Have you ever seen this loader:
rapidshare loader
Or this one:
drop.io loader

They are used to show the percentage of apload to the server of the file that you upload via the form. Unfortunately, at the simplest level it is impossible to show the percentage of upload, but we would like to. Agree to see the download percentage is always more pleasant than the boring “Loading ...” in the status bar of the browser, so I will tell you how to make such an apload indicator for your download forms.


To better understand what this is about, try a working example:
php5.bluga.net/UploadProgressMeter/demo.php
')
First, I installed a new http server Apache version 2.2.4 and not quite new PHP 5.2.0

I hope you will install these applications, I will only say that I did it under Windows so we will need to connect two .dll extensions to php if you don’t have them installed yet:
php_apc.dll
php_json.dll

To install these extensions, you need to put these files into the extensions folder of your server, to find out what this folder is, run phpinfo (); and look at the extension_dir variable (usually C: \ php \ ext)
In php.ini connect them:
extension = php_apc.dll
extension = php_json.dll

You should also set the parameters for php_apc, also in php.ini:
extension = php_apc.dll
apc.shm_segments = 1
apc.optimization = 0
apc.shm_size = 128
apc.ttl = 7200
apc.user_ttl = 7200
apc.num_files_hint = 1024
apc.mmap_file_mask = / tmp / apc.XXXXXX
apc.enable_cli = 1
apc.rfc1867 = On

Pay attention to the latest installation, namely apc.rfc1867, it directly relates to our task. more on APC settings here .

Install php_apc if you run the file inside the folder and get the following image:
apc

Check if the modules are loaded, this can be done with the function extension_loaded

Now create a php file and paste into it such a text such text everything should work, it uses the Yahoo! To create a moving loading bar, you can use something of your own.

Perhaps you will have to work remotely with the server:
www.odessa.net/docs/LINUX/SHELL/shell.html

Now there is an uploadprogressextension for such purposes, this is of course also an option, but I don’t like to download a server with extra extensions, and php_apc and php_json would be worth it.
Thanks for attention.

Source: https://habr.com/ru/post/17620/


All Articles