Limiting Parallel/Simultaneous Downloads - How to know if download was cancelled?

后端 未结 3 962
一整个雨季
一整个雨季 2021-01-01 08:50

I have a simple file upload service, written out in PHP, which also includes a script that controls download speeds by sending limited-sized packets when a user requests a d

3条回答
  •  醉话见心
    2021-01-01 08:55

    file = $file;
      }
    
      public function send() {
        // -> note in DB you've started
        readfile($this->file);
      }
    
      public function __destruct() {
        // download is done, either completed or aborted
        $aborted = connection_aborted();
        // -> note in DB
      }
    }
    
    $dl = new DownloadObserver("/tmp/whatever");
    $dl->send();
    

    should work just fine. No need for a shutdown_function or any funky self-built connection observation.

提交回复
热议问题