当前位置: 首页>>代码示例>>PHP>>正文


PHP FileModel::mime方法代码示例

本文整理汇总了PHP中FileModel::mime方法的典型用法代码示例。如果您正苦于以下问题:PHP FileModel::mime方法的具体用法?PHP FileModel::mime怎么用?PHP FileModel::mime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileModel的用法示例。


在下文中一共展示了FileModel::mime方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: foreach

    foreach (explode("\n", $out) as $row) {
        if (!empty($row)) {
            $rows[] = new TableRow(new FileModel($row), $fields);
        }
    }
    $middle = render_str('foobar/table', compact('fields', 'rows'));
} else {
    $file = new FileModel($f);
    if (is_dir($f)) {
        $fields = array(new TableFieldIcon(), new TableFieldLink('Name', 'basename', function (FileModel $file) {
            return url(array('q' => false, 'f' => $file->path()));
        }), new TableField('Type', 'type'), new TableFieldFormat('Size', 'size', 'format_bytes'), new TableField('MIME', 'mime'), new TableField('Owner', 'owner'), new TableField('Group', 'group'), new TableField('Permissions', 'perms'));
        $rows = $file->rows();
        $middle = render_str('foobar/table', array('fields' => $fields, 'rows' => new TableRowGenerator($rows, $fields)));
    } else {
        switch ($file->mime()) {
            case 'audio/mpeg':
                if (begins($file->realpath(), $_SERVER['DOCUMENT_ROOT'])) {
                    $middle = render_str('foobar/audio', array('src' => replace_prefix($file->realpath(), $_SERVER['DOCUMENT_ROOT'], '/')));
                } else {
                    $middle = render_str('foobar/audio', array('src' => 'image.php?' . http_build_query(array('f' => $file->realpath()))));
                }
                break;
            case 'video/mp4':
                if (begins($file->realpath(), $_SERVER['DOCUMENT_ROOT'])) {
                    $middle = render_str('foobar/video', array('src' => replace_prefix($file->realpath(), $_SERVER['DOCUMENT_ROOT'], '/')));
                } else {
                    $middle = render_str('foobar/video', array('src' => 'image.php?' . http_build_query(array('f' => $file->realpath()))));
                }
                break;
            case 'image/svg+xml':
开发者ID:vbarbarosh,项目名称:app_file_manager,代码行数:31,代码来源:index.php

示例2: header

<?php

require __DIR__ . '/../share/app.php';
if (empty($_GET['f'])) {
    header('HTTP/1.1 404 Not Found');
    render('page/404');
    exit;
}
$f = $_GET['f'];
if (!file_exists($f)) {
    header('HTTP/1.1 404 Not Found');
    render('page/404');
    exit;
}
$file = new FileModel($_GET['f']);
switch ($file->mime()) {
    case 'video/mp4':
    case 'image/svg+xml':
    case 'image/png':
    case 'image/jpeg':
    case 'image/gif':
        $image = true;
        break;
    default:
        $image = false;
        break;
}
if (!$image || !is_readable($f)) {
    header('HTTP/1.1 403 Permission denied');
    render('page/403', array('message' => 'Permission denied'));
    exit;
开发者ID:vbarbarosh,项目名称:app_file_manager,代码行数:31,代码来源:image.php

示例3: format_file_glyphicon

function format_file_glyphicon(FileModel $file)
{
    if ($file->type() == 'dir') {
        return 'glyphicon glyphicon-folder-close';
    }
    switch ($file->mime()) {
        case 'image/gif':
        case 'image/jpeg':
        case 'image/png':
        case 'image/svg+xml':
        case 'image/tiff':
        case 'image/vnd.microsoft.icon':
        case 'image/x-ms-bmp':
            return 'glyphicon glyphicon-picture';
        case 'video/3gpp':
        case 'video/annodex':
        case 'video/dl':
        case 'video/dv':
        case 'video/fli':
        case 'video/gl':
        case 'video/mpeg':
        case 'video/MP2T':
        case 'video/mp4':
        case 'video/quicktime':
        case 'video/mp4v-es':
        case 'video/ogg':
        case 'video/parityfec':
        case 'video/pointer':
        case 'video/webm':
        case 'video/vnd.fvt':
        case 'video/vnd.motorola.video':
        case 'video/vnd.motorola.videop':
        case 'video/vnd.mpegurl':
        case 'video/vnd.mts':
        case 'video/vnd.nokia.interleaved-multimedia':
        case 'video/vnd.vivo':
        case 'video/x-flv':
        case 'video/x-la-asf':
        case 'video/x-mng':
        case 'video/x-ms-asf':
        case 'video/x-ms-wm':
        case 'video/x-ms-wmv':
        case 'video/x-ms-wmx':
        case 'video/x-ms-wvx':
        case 'video/x-msvideo':
        case 'video/x-sgi-movie':
        case 'video/x-matroska':
            return 'glyphicon glyphicon-film';
        case 'audio/32kadpcm':
        case 'audio/3gpp':
        case 'audio/amr':
        case 'audio/amr-wb':
        case 'audio/annodex':
        case 'audio/basic':
        case 'audio/csound':
        case 'audio/flac':
        case 'audio/g.722.1':
        case 'audio/l16':
        case 'audio/midi':
        case 'audio/mp4a-latm':
        case 'audio/mpa-robust':
        case 'audio/mpeg':
        case 'audio/mpegurl':
        case 'audio/ogg':
        case 'audio/parityfec':
        case 'audio/prs.sid':
        case 'audio/telephone-event':
        case 'audio/tone':
        case 'audio/vnd.cisco.nse':
        case 'audio/vnd.cns.anp1':
        case 'audio/vnd.cns.inf1':
        case 'audio/vnd.digital-winds':
        case 'audio/vnd.everad.plj':
        case 'audio/vnd.lucent.voice':
        case 'audio/vnd.nortel.vbk':
        case 'audio/vnd.nuera.ecelp4800':
        case 'audio/vnd.nuera.ecelp7470':
        case 'audio/vnd.nuera.ecelp9600':
        case 'audio/vnd.octel.sbc':
        case 'audio/vnd.qcelp':
        case 'audio/vnd.rhetorex.32kadpcm':
        case 'audio/vnd.vmx.cvsd':
        case 'audio/x-aiff':
        case 'audio/x-gsm':
        case 'audio/x-mpegurl':
        case 'audio/x-ms-wma':
        case 'audio/x-ms-wax':
        case 'audio/x-pn-realaudio-plugin':
        case 'audio/x-pn-realaudio':
        case 'audio/x-realaudio':
        case 'audio/x-scpls':
        case 'audio/x-sd2':
        case 'audio/x-wav':
            return 'glyphicon glyphicon-music';
        default:
            return 'glyphicon glyphicon-file';
    }
}
开发者ID:vbarbarosh,项目名称:app_file_manager,代码行数:98,代码来源:format.php


注:本文中的FileModel::mime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。