Can php check whether the user has started uploading?

Source: Internet
Author: User
Php can detect whether a user has started downloading a project to download files, because it needs to check whether the user has completed downloading. there is a piece of code below... ignore_user_abort (true); if & nbsp; ($ fd & nbsp; = & nbsp; fopen ($ filePath, & nbsp; 'RB ')) & php: Check whether the user has started downloading
There is a project that provides file download, because you need to check whether the user has completed the download, there is a piece of code below

if ($fd = fopen($filePath, 'rb')) {
if ($start_offset > 0)
            fseek($fd, $start_offset);
while (!feof($fd)) {
     print (fread($fd, 16384));

if (connection_aborted()){
else {

Now, a problem occurs: if it is a large file, there is nothing to do. if it is a small file, when the user sees the select storage directory dialog box, wait a moment and then click cancel, the server has sent all files, so if (connection_aborted () is false.
I want to ask if there is any way. for example, if a user finds that the first print has not started downloading, print is paused, or is there a way to disable a print such as buffering so that the print block is not accepted by the user, that is, the print cannot be returned?

Unclear explanation
------ Solution --------------------
PHP cannot know.
------ Solution --------------------
PHP server script, that is the behavior of the browser, php is powerless.
------ Solution --------------------
Put if (connection_aborted () {... in a loop
------ Solution --------------------
The server sends the header followed by the file data
After the browser receives the header, it immediately receives subsequent data. While parsing the header in the browser, the download has started, but it is downloaded to the cache.
------ Solution --------------------

The underlying protocol has nothing to do with the language. if both parties agree, php can also

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.