public function download($path, $removeDownloadedFile = false)
    {
        if(!file_exists($path)) {
            throw new Exception("File [ $path ] not found.");
        }

        $filename = pathinfo($path, PATHINFO_BASENAME );

        header("Content-Description: File Transfer");
        header("Content-Type: application/octet-stream");
        header("Content-Disposition: attachment; filename=\"$filename\"");

        @readfile($path);

        if($removeDownloadedFile) {
            @unlink($path);
        }
    }
public function download($path, $removeDownloadedFile = false)
    {
        if(!file_exists($path)) {
            throw new Exception("File [ $path ] not found.");
        }

        $filename = pathinfo($path, PATHINFO_BASENAME );

        header("Content-Description: File Transfer");
        header("Content-Type: application/octet-stream");
        header("Content-Disposition: attachment; filename=\"$filename\"");

        @readfile($path);

        if($removeDownloadedFile) {
            @unlink($path);
        }
    }
public function download ( $ path , $ removeDownloadedFile = false ) { if ( ! file_exists ( $ path ) ) { throw new Exception ( "File [ $path ] not found." ) ; } $ filename = pathinfo ( $ path , PATHINFO_BASENAME ) ; header ( "Content-Description: File Transfer" ) ; header ( "Content-Type: application/octet-stream" ) ; header ( "Content-Disposition: attachment; filename=\"$filename\"" ) ; @ readfile ( $ path ) ; if ( $ removeDownloadedFile ) { @ unlink ( $ path ) ; } }
Http Response to download file

@param string $path
@param bool   $removeDownloadedFile

@throws Exception
Http Response to download file