本文整理汇总了PHP中DocumentManager::file_get_mime_type方法的典型用法代码示例。如果您正苦于以下问题:PHP DocumentManager::file_get_mime_type方法的具体用法?PHP DocumentManager::file_get_mime_type怎么用?PHP DocumentManager::file_get_mime_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentManager
的用法示例。
在下文中一共展示了DocumentManager::file_get_mime_type方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: intval
Display::display_header($nameTools, 'Dropbox');
Display::display_error_message(get_lang('YouAreNotAllowedToDownloadThisFile'));
Display::display_footer();
exit;
} else {
/* DOWNLOAD THE FILE */
// the user is allowed to download the file
$_SESSION['_seen'][$_course['id']][TOOL_DROPBOX][] = intval($_GET['id']);
$work = new Dropbox_Work($_GET['id']);
$path = dropbox_cnf('sysPath') . '/' . $work->filename;
//path to file as stored on server
if (!Security::check_abs_path($path, dropbox_cnf('sysPath') . '/')) {
exit;
}
$file = $work->title;
$mimetype = DocumentManager::file_get_mime_type(true);
$fileinfo = pathinfo($file);
$extension = $fileinfo['extension'];
if (!empty($extension) && isset($mimetype[$extension]) && $_GET['action'] != 'download') {
// give hint to browser about filetype
header('Content-type: ' . $mimetype[$extension] . "\n");
} else {
//no information about filetype: force a download dialog window in browser
header("Content-type: application/octet-stream\n");
}
header('Content-Disposition: attachment; filename=' . $file);
/**
* Note that if you use these two headers from a previous example:
* header('Cache-Control: no-cache, must-revalidate');
* header('Pragma: no-cache');
* before sending a file to the browser, the "Open" option on Internet Explorer's file download dialog will not work properly. If the user clicks "Open" instead of "Save," the target application will open an empty file, because the downloaded file was not cached. The user will have to save the file to their hard drive in order to use it.
示例2: array
/**
* Script to find a document with a specific title or path in all courses
*/
/**
* Code init - comment die() call to enable
*/
die;
require '../../inc/global.inc.php';
require_once '../../inc/lib/course.lib.php';
require_once '../../inc/lib/document.lib.php';
if (empty($_GET['doc'])) {
echo "To add a document name to search, add ?doc=abc to the URL\n";
} else {
echo "Received param " . $_GET['doc'] . "<br />\n";
}
$allowed_mime_types = DocumentManager::file_get_mime_type(true);
$allowed_extensions = array('doc', 'docx', 'ppt', 'pptx', 'pps', 'ppsx', 'xls', 'xlsx', 'odt', 'odp', 'ods', 'pdf', 'txt', 'rtf', 'msg', 'csv', 'html', 'htm');
$courses_list = CourseManager::get_courses_list();
// Simulating empty specific fields (this is necessary for indexing)
require_once api_get_path(LIBRARY_PATH) . 'specific_fields_manager.lib.php';
$specific_fields = get_specific_field_list();
$specific_fields_values = array();
foreach ($specific_fields as $sf) {
$specific_fields_values[$sf['code']] = '';
}
$td = Database::get_course_table(TABLE_DOCUMENT);
foreach ($courses_list as $course) {
$course_dir = $course['directory'] . '/document';
$title = Database::escape_string($_GET['doc']);
$sql = "SELECT id, path, session_id FROM {$td} WHERE c_id = " . $course['id'] . " AND path LIKE '%{$title}%' or title LIKE '%{$title}%'";
$res = Database::query($sql);
示例3: mime_content_type
function mime_content_type($filename)
{
return DocumentManager::file_get_mime_type((string) $filename);
}
示例4: mdo_add_breadcrump_nav
function mdo_add_breadcrump_nav()
{
global $interbreadcrumb, $langFormats;
$regs = array();
// for use with ereg()
$docurl = api_get_self();
// should be .../main/xxx/yyy.php
if (ereg('^(.+[^/\\.]+)/[^/\\.]+/[^/\\.]+.[^/\\.]+$', $docurl, $regs)) {
$docurl = $regs[1] . '/document/document.php';
}
$interbreadcrumb[] = array('url' => $docurl, "name" => get_lang('MdCallingTool'));
if ($docpath = $this->mdo_path) {
$docpath = substr($docpath, 0, strrpos($docpath, '/'));
if (strlen($docpath) > 1) {
$interbreadcrumb[] = array('url' => $docurl . '?curdirpath=' . urlencode($docpath) . ($this->mdo_group ? '&gidReq=' . $this->mdo_group : ''), "name" => htmlspecialchars(substr($docpath, strrpos($docpath, '/') + 1)));
}
}
// Complete assoclist $langFormats from mime types
require_once api_get_path(LIBRARY_PATH) . 'xht.lib.php';
require_once api_get_path(LIBRARY_PATH) . 'document.lib.php';
$sep = $langFormats[0] ? $langFormats[0] : ":";
$arrFormats = xht_explode_assoclist($langFormats);
foreach (DocumentManager::file_get_mime_type(TRUE) as $format) {
if (!isset($arrFormats[$format])) {
$langFormats .= ",, " . $format . $sep . $format;
}
}
if (!isset($arrFormats["inode/directory"])) {
$langFormats .= ",, inode/directory" . $sep . "inode/directory";
}
if (substr($langFormats, 0, 3) == ",, ") {
$langFormats = $sep . substr($langFormats, 3);
}
}