$filename = 'abc.txt'; $str = Auth::guard('admin')->id(); header("Content-type: text/plain"); header("Accept-Ranges: bytes"); header("Content-Disposition: attachment; filename=".$filename); header("Cache-Control: must-revalidate, post-check=0, pre-check=0" ); header("Pragma: no-cache" ); header("Expires: 0" ); exit($str);