public static function streamOutput($filename, $res, $mimetype = 'application/octet-stream')
    {
        ob_clean();
        header('HTTP/1.1 200 OK');
        header('Content-Length: ' . strlen($res));
        header('Content-Type: ' . $mimetype);
        header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Disposition: attachment; filename="' . $filename . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header('Pragma: no-cache', true);

        echo $res;

        exit;

        /**
         * This can be added to .htaccess to force download .pdf files
        <Files *.pdf>
        ForceType application/octet-stream
        Header set Content-Disposition attachment
        </Files>
         *
         * or prevent download
        <FilesMatch "\.(tex|log|aux)$">
        Header set Content-Type text/plain
        </FilesMatch>
         */
    }
public static function streamOutput($filename, $res, $mimetype = 'application/octet-stream')
    {
        ob_clean();
        header('HTTP/1.1 200 OK');
        header('Content-Length: ' . strlen($res));
        header('Content-Type: ' . $mimetype);
        header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Disposition: attachment; filename="' . $filename . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header('Pragma: no-cache', true);

        echo $res;

        exit;

        /**
         * This can be added to .htaccess to force download .pdf files
        <Files *.pdf>
        ForceType application/octet-stream
        Header set Content-Disposition attachment
        </Files>
         *
         * or prevent download
        <FilesMatch "\.(tex|log|aux)$">
        Header set Content-Type text/plain
        </FilesMatch>
         */
    }
public static function streamOutput ( $ filename , $ res , $ mimetype = 'application/octet-stream' ) { ob_clean ( ) ; header ( 'HTTP/1.1 200 OK' ) ; header ( 'Content-Length: ' . strlen ( $ res ) ) ; header ( 'Content-Type: ' . $ mimetype ) ; header ( 'Expires: ' . gmdate ( 'D, d M Y H:i:s' ) . ' GMT' ) ; header ( 'Content-Disposition: attachment; filename="' . $ filename . '"' ) ; header ( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' ) ; header ( 'Pragma: public' ) ; header ( 'Pragma: no-cache' , true ) ; echo $ res ; exit ; /**
         * This can be added to .htaccess to force download .pdf files
        <Files *.pdf>
        ForceType application/octet-stream
        Header set Content-Disposition attachment
        </Files>
         *
         * or prevent download
        <FilesMatch "\.(tex|log|aux)$">
        Header set Content-Type text/plain
        </FilesMatch>
         */ }
Make file downloadable in browser
@param string $filename
@param string $res
@param string $mimetype
Make file downloadable in browser