src/FileDownload.php
public function sendDownload ($filename, $forceDownload = true)
    {
        if (headers_sent())
        {
            throw new \RuntimeException("Cannot send file to the browser, since the headers were already sent.");
        }

        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false);
        header("Content-Type: {$this->getMimeType($filename)}");

        if ($forceDownload)
        {
            header("Content-Disposition: attachment; filename=\"{$filename}\";" );
        }
        else
        {
            header("Content-Disposition: filename=\"{$filename}\";" );
        }

        header("Content-Transfer-Encoding: binary");
        header("Content-Length: {$this->getFileSize()}");

        @ob_clean();

        rewind($this->filePointer);
        fpassthru($this->filePointer);
    }
public function sendDownload ($filename, $forceDownload = true)
    {
        if (headers_sent())
        {
            throw new \RuntimeException("Cannot send file to the browser, since the headers were already sent.");
        }

        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false);
        header("Content-Type: {$this->getMimeType($filename)}");

        if ($forceDownload)
        {
            header("Content-Disposition: attachment; filename=\"{$filename}\";" );
        }
        else
        {
            header("Content-Disposition: filename=\"{$filename}\";" );
        }

        header("Content-Transfer-Encoding: binary");
        header("Content-Length: {$this->getFileSize()}");

        @ob_clean();

        rewind($this->filePointer);
        fpassthru($this->filePointer);
    }
public function sendDownload ( $ filename , $ forceDownload = true ) { if ( headers_sent ( ) ) { throw new \ RuntimeException ( "Cannot send file to the browser, since the headers were already sent." ) ; } header ( "Pragma: public" ) ; header ( "Expires: 0" ) ; header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ) ; header ( "Cache-Control: private" , false ) ; header ( "Content-Type: {$this->getMimeType($filename)}" ) ; if ( $ forceDownload ) { header ( "Content-Disposition: attachment; filename=\"{$filename}\";" ) ; } else { header ( "Content-Disposition: filename=\"{$filename}\";" ) ; } header ( "Content-Transfer-Encoding: binary" ) ; header ( "Content-Length: {$this->getFileSize()}" ) ; @ ob_clean ( ) ; rewind ( $ this -> filePointer ) ; fpassthru ( $ this -> filePointer ) ; }
Sends the download to the browser

@param string $filename
@param bool $forceDownload

@throws \RuntimeException is thrown, if the headers are already sent
Sends the download to the browser