public static function readFile($file, $download_name = null) { if (empty($download_name)) { $download_name = basename($file); } $fsize = filesize($file); header("Cache-Control: public, must-revalidate"); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); if (!preg_match('#MSIE#', $_SERVER['HTTP_USER_AGENT'])) { header("Pragma: no-cache"); } header("Expires: 0"); header("Content-Description: File Transfer"); header("Expires: Sat, 01 Jan 2000 01:00:00 GMT"); if (preg_match('#Opera#', $_SERVER['HTTP_USER_AGENT'])) { header("Content-Type: application/octetstream"); } else { header("Content-Type: application/octet-stream"); } header("Content-Length: " . (string) $fsize); header('Content-Disposition: attachment; filename="' . $download_name . '"'); header("Content-Transfer-Encoding: binary\n"); ob_end_flush(); RSFormProHelper::readFileChunked($file); exit; }
public static function readFile($file, $download_name = null) { jimport('joomla.filesystem.file'); $ext = strtolower(JFile::getExt($file)); if ($ext == 'tgz' || $ext == 'gz') { // Needed when some servers with GZIP compression perform double encoding if (is_callable('ini_set')) { if (is_callable('ini_get') && ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); } ini_set('output_buffering', 'Off'); ini_set('output_handler', ''); } header('Content-Encoding: none'); } if (empty($download_name)) { $download_name = basename($file); } $fsize = filesize($file); header("Cache-Control: public, must-revalidate"); header('Cache-Control: pre-check=0, post-check=0, max-age=0'); if (!preg_match('#MSIE#', $_SERVER['HTTP_USER_AGENT'])) { header("Pragma: no-cache"); } header("Expires: 0"); header("Content-Description: File Transfer"); header("Expires: Sat, 01 Jan 2000 01:00:00 GMT"); if (preg_match('#Opera#', $_SERVER['HTTP_USER_AGENT'])) { header("Content-Type: application/octetstream"); } else { header("Content-Type: application/octet-stream"); } header("Content-Length: " . (string) $fsize); header('Content-Disposition: attachment; filename="' . $download_name . '"'); header("Content-Transfer-Encoding: binary\n"); ob_end_flush(); RSFormProHelper::readFileChunked($file); exit; }