public function download($file, $filename = null, array $headers = [], $disposition = 'attachment')
    {
        $type = mime_content_type($file);

        if ($filename == null) {
            $filename = basename($file);
        }

        $this->addHeader('Content-Disposition', $disposition.'; filename='.$filename);

        $this->addHeader('Content-Type', $type);

        $this->addHeader('Content-Length', filesize($file));

        $this->addHeader('Content-Encoding', 'base64');

        foreach ($headers as $key => $value) {
            $this->addHeader($key, $value);
        }

        $this->download_filename = $file;

        $this->download = true;

        return $this->buildHttpResponse();
    }
public function download($file, $filename = null, array $headers = [], $disposition = 'attachment')
    {
        $type = mime_content_type($file);

        if ($filename == null) {
            $filename = basename($file);
        }

        $this->addHeader('Content-Disposition', $disposition.'; filename='.$filename);

        $this->addHeader('Content-Type', $type);

        $this->addHeader('Content-Length', filesize($file));

        $this->addHeader('Content-Encoding', 'base64');

        foreach ($headers as $key => $value) {
            $this->addHeader($key, $value);
        }

        $this->download_filename = $file;

        $this->download = true;

        return $this->buildHttpResponse();
    }
public function download ( $ file , $ filename = null , array $ headers = [ ] , $ disposition = 'attachment' ) { $ type = mime_content_type ( $ file ) ; if ( $ filename == null ) { $ filename = basename ( $ file ) ; } $ this -> addHeader ( 'Content-Disposition' , $ disposition . '; filename=' . $ filename ) ; $ this -> addHeader ( 'Content-Type' , $ type ) ; $ this -> addHeader ( 'Content-Length' , filesize ( $ file ) ) ; $ this -> addHeader ( 'Content-Encoding' , 'base64' ) ; foreach ( $ headers as $ key => $ value ) { $ this -> addHeader ( $ key , $ value ) ; } $ this -> download_filename = $ file ; $ this -> download = true ; return $ this -> buildHttpResponse ( ) ; }
Download the given file as an argument

@param string $file
@param null   $filename
@param array  $headers
@param string $disposition
@return string
Download the given file as an argument