本文整理匯總了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);
}
}