Core/Toolbox/IO/Sendfile.php
public function send()
    {
        if (!file_exists($this->filename)) {

            $error = sprintf('File "%s" not found.');

            if (isset($this->logger)) {
                $this->logger->critical($error);
            }

            Throw new FileException($error);
        }

        // No content type provided?
        if (empty($this->content_type)) {
            $this->content_type = $this->getMimeType($this->filename);
        }

        // Do we have to find out the filename by our own?
        if (empty($this->name)) {
            $this->name = basename($this->filename);
        }

        // Send headers
        $this->addHeaders([
            'Content-type: ' . $this->content_type,
            'Content-Disposition: ' . $this->inline ? 'inline' : 'attachement' . '; filename="' . $this->name . '"',
            'Content-Transfer-Encoding: binary',
            'Content-Length: ' . filesize($this->filename),
            'Accept-Ranges: bytes'
        ]);

        foreach ($this->headers as $header) {
            header($header);
        }

        // Clean buffer!
        ob_clean();
        flush();

        if ($this->download_rate > 0) {

            // Open file
            $stream = fopen($this->filename, "r");

            while (!feof($stream)) {

                // Send current file part to the browser
                print fread($stream, round($this->download_rate * 1024));

                // Flush content to the browser
                flush();

                // Sleep one second
                sleep(1);
            }
            fclose($this->filename);
        }
        else {
            readfile($this->filename);
        }

        exit();
    }
public function send()
    {
        if (!file_exists($this->filename)) {

            $error = sprintf('File "%s" not found.');

            if (isset($this->logger)) {
                $this->logger->critical($error);
            }

            Throw new FileException($error);
        }

        // No content type provided?
        if (empty($this->content_type)) {
            $this->content_type = $this->getMimeType($this->filename);
        }

        // Do we have to find out the filename by our own?
        if (empty($this->name)) {
            $this->name = basename($this->filename);
        }

        // Send headers
        $this->addHeaders([
            'Content-type: ' . $this->content_type,
            'Content-Disposition: ' . $this->inline ? 'inline' : 'attachement' . '; filename="' . $this->name . '"',
            'Content-Transfer-Encoding: binary',
            'Content-Length: ' . filesize($this->filename),
            'Accept-Ranges: bytes'
        ]);

        foreach ($this->headers as $header) {
            header($header);
        }

        // Clean buffer!
        ob_clean();
        flush();

        if ($this->download_rate > 0) {

            // Open file
            $stream = fopen($this->filename, "r");

            while (!feof($stream)) {

                // Send current file part to the browser
                print fread($stream, round($this->download_rate * 1024));

                // Flush content to the browser
                flush();

                // Sleep one second
                sleep(1);
            }
            fclose($this->filename);
        }
        else {
            readfile($this->filename);
        }

        exit();
    }
Sends file to browser