/** * Force a file download by setting headers. * @param string path to file * @param string extension * @param string file name on client side * @example download('folder/error_log.pdf') * @example download('folder/error_log.pdf', 'pdf' ,'log.pdf') * @return boolean */ public static function download($path = false, $extension = false, $name = false) { if ($path && File::isFile($path)) { if (!$extension) { $extension = File::extension($path); } if (!$name) { $name = basename($path); } header('Content-Type: application/' . $extension); header("Content-Transfer-Encoding: Binary"); header("Content-disposition: attachment; filename=" . $name); readfile($path); exit; } return false; }
/** * Check if given input is a ZIP file. * @param string path to file * @return boolean */ public static function isZip($input = false) { if ($input) { if (File::isFile($input) && File::extension($input) === 'zip') { return true; } } return false; }