public function download_file($file, $unlink = true) { if (ob_get_contents()) { ob_end_clean(); } if (file_exists($file)) { $mime_type = RM_Utilities::mime_content_type($file); header('Content-Description: File Transfer'); header('Content-Type: ' . $mime_type); header('Content-Disposition: attachment; filename="' . basename($file) . '"'); header('Expires: 0'); readfile($file); if ($unlink) { unlink($file); } exit; } else { return false; } return true; }