protected function render($filepath, $data = NULL) {
        if (!file_exists($filepath)) {
            throw new \RuntimeException("View cannot render `$filepath` because the template does not exist");
        }

        $data = $this->getData();

        $contentType = 'application/octet-stream';

        if (isset($data["CONTENT_TYPE"])) {
            $cType = $data["CONTENT_TYPE"];

            if (!empty($cType)) {
                $contentType = $cType;
            }
        }

        $filename = basename($filepath);

        if (isset($data["FILENAME"])) {
            $fname = $data["FILENAME"];

            if (!empty($fname)) {
                $filename = $fname;
            }
        }

        header("HTTP/1.1 200 OK");
        header("Content-type: " . $contentType);
        header('Content-Transfer-Encoding: binary');
        header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
        header("Content-Length: " . filesize($filepath));
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Pragma: public");
        ob_clean();
        ob_start();
        readfile($filepath);
        return ob_get_clean();
    }
protected function render($filepath, $data = NULL) {
        if (!file_exists($filepath)) {
            throw new \RuntimeException("View cannot render `$filepath` because the template does not exist");
        }

        $data = $this->getData();

        $contentType = 'application/octet-stream';

        if (isset($data["CONTENT_TYPE"])) {
            $cType = $data["CONTENT_TYPE"];

            if (!empty($cType)) {
                $contentType = $cType;
            }
        }

        $filename = basename($filepath);

        if (isset($data["FILENAME"])) {
            $fname = $data["FILENAME"];

            if (!empty($fname)) {
                $filename = $fname;
            }
        }

        header("HTTP/1.1 200 OK");
        header("Content-type: " . $contentType);
        header('Content-Transfer-Encoding: binary');
        header("Content-Disposition: attachment; filename=\"" . $filename . "\"");
        header("Content-Length: " . filesize($filepath));
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Pragma: public");
        ob_clean();
        ob_start();
        readfile($filepath);
        return ob_get_clean();
    }
protected function render ( $ filepath , $ data = NULL ) { if ( ! file_exists ( $ filepath ) ) { throw new \ RuntimeException ( "View cannot render `$filepath` because the template does not exist" ) ; } $ data = $ this -> getData ( ) ; $ contentType = 'application/octet-stream' ; if ( isset ( $ data [ "CONTENT_TYPE" ] ) ) { $ cType = $ data [ "CONTENT_TYPE" ] ; if ( ! empty ( $ cType ) ) { $ contentType = $ cType ; } } $ filename = basename ( $ filepath ) ; if ( isset ( $ data [ "FILENAME" ] ) ) { $ fname = $ data [ "FILENAME" ] ; if ( ! empty ( $ fname ) ) { $ filename = $ fname ; } } header ( "HTTP/1.1 200 OK" ) ; header ( "Content-type: " . $ contentType ) ; header ( 'Content-Transfer-Encoding: binary' ) ; header ( "Content-Disposition: attachment; filename=\"" . $ filename . "\"" ) ; header ( "Content-Length: " . filesize ( $ filepath ) ) ; header ( "Expires: 0" ) ; header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ) ; header ( "Pragma: public" ) ; ob_clean ( ) ; ob_start ( ) ; readfile ( $ filepath ) ; return ob_get_clean ( ) ; }
Render -> Download file.
@param string $filepath Filepath
@param array|null $data
@return void
@throws \RuntimeException
Render - > Download file .