Home > Article > Backend Development > PHP continues to maintain long connections, uses flush to continuously update the browser UI, and implements download progress bars.
How to use PHP+JS to implement the upload progress bar? Most people may have implemented it, but what about downloading? How? The principle is similar, that is, reading and writing in batches, and how many bytes are read each time. However, the disadvantage of this is that the connection is long. Generally, the two solutions commonly used to implement the download progress bar are: one is to use a socket to maintain communication with the client. For communication, keep a long connection, use flush() to continuously update the browser UI, return the size of the downloaded data, and then display the download speed, progress bar, etc.; the second one is to interact with php and flash to display the progress bar.
文件大小 | 未知长度 |
已经下载 | 0 |
完成进度 | 0% |
The above introduces how PHP continues to maintain long connections, uses flush to continuously update the browser UI, and implements download progress bars, including aspects of this. I hope it will be helpful to friends who are interested in PHP tutorials.