本文整理汇总了PHP中jFile::getExt方法的典型用法代码示例。如果您正苦于以下问题:PHP jFile::getExt方法的具体用法?PHP jFile::getExt怎么用?PHP jFile::getExt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jFile
的用法示例。
在下文中一共展示了jFile::getExt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: downloadFile
public static function downloadFile($cid, $type = '')
{
global $jlistConfig;
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$app = JFactory::getApplication();
$db = JFactory::getDBO();
clearstatcache();
$view_types = array();
$view_types = explode(',', $jlistConfig['file.types.view']);
// get path
$db->SetQuery("SELECT * FROM #__jdownloads_files WHERE file_id = {$cid}");
$file = $db->loadObject();
if ($type == 'prev') {
if ($file->preview_filename) {
$file = $jlistConfig['files.uploaddir'] . DS . $jlistConfig['preview.files.folder.name'] . DS . $file->preview_filename;
}
} else {
if ($file->url_download) {
if ($file->cat_id > 1) {
// 'uncategorised' download is NOT selected
$db->SetQuery("SELECT cat_dir, cat_dir_parent FROM #__jdownloads_categories WHERE id = {$file->cat_id}");
$cat_dirs = $db->loadObject();
// build the complete stored category path
if ($cat_dirs->cat_dir_parent != '') {
$cat_dir = $cat_dirs->cat_dir_parent . DS . $cat_dirs->cat_dir;
} else {
$cat_dir = $cat_dirs->cat_dir;
}
$filename_direct = $jlistConfig['files.uploaddir'] . DS . $cat_dir . DS . $file->url_download;
$file = $jlistConfig['files.uploaddir'] . DS . $cat_dir . DS . $file->url_download;
} else {
// 'uncategorised' download IS selected
$file = $jlistConfig['files.uploaddir'] . DS . $jlistConfig['uncategorised.files.folder.name'] . DS . $file->url_download;
}
}
}
if (!jFile::exists($file)) {
exit;
}
$len = filesize($file);
// if set the option for direct link to the file
if (!$jlistConfig['use.php.script.for.download']) {
if (empty($filename_direct)) {
$app->redirect($file);
} else {
$app->redirect($filename_direct);
}
} else {
$filename = basename($file);
$file_extension = jFile::getExt($filename);
$ctype = self::datei_mime($file_extension);
ob_end_clean();
// needed for MS IE - otherwise content disposition is not used?
if (ini_get('zlib.output_compression')) {
ini_set('zlib.output_compression', 'Off');
}
header("Cache-Control: public, must-revalidate");
header('Cache-Control: pre-check=0, post-check=0, max-age=0');
// header("Pragma: no-cache"); // Problems with MS IE
header("Expires: 0");
header("Content-Description: File Transfer");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
header("Content-Type: " . $ctype);
header("Content-Length: " . (string) $len);
if (!in_array($file_extension, $view_types)) {
header('Content-Disposition: attachment; filename="' . $filename . '"');
} else {
// view file in browser
header('Content-Disposition: inline; filename="' . $filename . '"');
}
header("Content-Transfer-Encoding: binary\n");
// set_time_limit doesn't work in safe mode
if (!ini_get('safe_mode')) {
@set_time_limit(0);
}
@readfile($file);
}
exit;
}