concrete/src/File/Service/File.php
public function forceDownload($file)
    {
        session_write_close();
        ob_clean();
        header('Content-type: application/octet-stream');
        $filename = basename($file);
        header("Content-Disposition: attachment; filename=\"$filename\"");
        header('Content-Length: ' . filesize($file));
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false);
        header("Content-Transfer-Encoding: binary");
        header("Content-Encoding: plainbinary");

        // This code isn't ready yet. It will allow us to no longer force download

        /*
        $h = Core::make('helper/mime');
        $mimeType = $h->mimeFromExtension($this->getExtension($file));
        header('Content-type: ' . $mimeType);
        */

        $buffer = '';
        $chunk = 1024 * 1024;
        $handle = fopen($file, 'rb');
        if ($handle === false) {
            return false;
        }
        while (!feof($handle)) {
            $buffer = fread($handle, $chunk);
            echo $buffer;
        }

        fclose($handle);
        exit;
    }
public function forceDownload($file)
    {
        session_write_close();
        ob_clean();
        header('Content-type: application/octet-stream');
        $filename = basename($file);
        header("Content-Disposition: attachment; filename=\"$filename\"");
        header('Content-Length: ' . filesize($file));
        header("Pragma: public");
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false);
        header("Content-Transfer-Encoding: binary");
        header("Content-Encoding: plainbinary");

        // This code isn't ready yet. It will allow us to no longer force download

        /*
        $h = Core::make('helper/mime');
        $mimeType = $h->mimeFromExtension($this->getExtension($file));
        header('Content-type: ' . $mimeType);
        */

        $buffer = '';
        $chunk = 1024 * 1024;
        $handle = fopen($file, 'rb');
        if ($handle === false) {
            return false;
        }
        while (!feof($handle)) {
            $buffer = fread($handle, $chunk);
            echo $buffer;
        }

        fclose($handle);
        exit;
    }
public function forceDownload ( $ file ) { session_write_close ( ) ; ob_clean ( ) ; header ( 'Content-type: application/octet-stream' ) ; $ filename = basename ( $ file ) ; header ( "Content-Disposition: attachment; filename=\"$filename\"" ) ; header ( 'Content-Length: ' . filesize ( $ file ) ) ; header ( "Pragma: public" ) ; header ( "Expires: 0" ) ; header ( "Cache-Control: must-revalidate, post-check=0, pre-check=0" ) ; header ( "Cache-Control: private" , false ) ; header ( "Content-Transfer-Encoding: binary" ) ; header ( "Content-Encoding: plainbinary" ) ; // This code isn't ready yet. It will allow us to no longer force download /*
        $h = Core::make('helper/mime');
        $mimeType = $h->mimeFromExtension($this->getExtension($file));
        header('Content-type: ' . $mimeType);
        */ $ buffer = '' ; $ chunk = 1024 * 1024 ; $ handle = fopen ( $ file , 'rb' ) ; if ( $ handle === false ) { return false ; } while ( ! feof ( $ handle ) ) { $ buffer = fread ( $ handle , $ chunk ) ; echo $ buffer ; } fclose ( $ handle ) ; exit ; }
Takes a path to a file and sends it to the browser, streaming it, and closing the HTTP connection afterwards. Basically a force download method.

@param stings $file
Takes a path to a file and sends it to the browser streaming it and closing the HTTP connection afterwards . Basically a force download method .