Ejemplo n.º 1
0
 /**
  * Sends the actual file to the client.
  */
 protected function sendFile()
 {
     if ($this->startByte > 0 || $this->endByte < $this->options['filesize'] - 1) {
         $file = new File($this->location, 'rb');
         if ($this->startByte > 0) {
             $file->seek($this->startByte);
         }
         while ($this->startByte <= $this->endByte) {
             $remainingBytes = $this->endByte - $this->startByte;
             $readBytes = $remainingBytes > 1048576 ? 1048576 : $remainingBytes + 1;
             echo $file->read($readBytes);
             $this->startByte += $readBytes;
         }
         $file->close();
     } else {
         readfile($this->location);
     }
 }