• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP valid_src_mime_type函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中valid_src_mime_type函数的典型用法代码示例。如果您正苦于以下问题:PHP valid_src_mime_type函数的具体用法?PHP valid_src_mime_type怎么用?PHP valid_src_mime_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: mime_type

/**
 * determine the file mime type
 */
function mime_type($file)
{
    if (stristr(PHP_OS, 'WIN')) {
        $os = 'WIN';
    } else {
        $os = PHP_OS;
    }
    $mime_type = '';
    if (function_exists('mime_content_type') && $os != 'WIN') {
        $mime_type = mime_content_type($file);
    }
    // use PECL fileinfo to determine mime type
    if (!valid_src_mime_type($mime_type)) {
        if (function_exists('finfo_open')) {
            $finfo = @finfo_open(FILEINFO_MIME);
            if ($finfo != '') {
                $mime_type = finfo_file($finfo, $file);
                finfo_close($finfo);
            }
        }
    }
    // try to determine mime type by using unix file command
    // this should not be executed on windows
    if (!valid_src_mime_type($mime_type) && $os != "WIN") {
        if (preg_match("/FreeBSD|FREEBSD|LINUX/", $os)) {
            $mime_type = trim(@shell_exec('file -bi ' . escapeshellarg($file)));
        }
    }
    // use file's extension to determine mime type
    if (!valid_src_mime_type($mime_type)) {
        // set defaults
        $mime_type = 'image/png';
        // file details
        $fileDetails = pathinfo($file);
        $ext = strtolower($fileDetails["extension"]);
        // mime types
        $types = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif');
        if (strlen($ext) && strlen($types[$ext])) {
            $mime_type = $types[$ext];
        }
    }
    return $mime_type;
}
开发者ID:OvayoMonti,项目名称:showofhands,代码行数:46,代码来源:timthumb.php


示例2: mime_type

function mime_type($file)
{
    $os = strtolower(php_uname());
    $mime_type = '';
    // use PECL fileinfo to determine mime type
    if (function_exists('finfo_open')) {
        $finfo = finfo_open(FILEINFO_MIME);
        $mime_type = finfo_file($finfo, $file);
        finfo_close($finfo);
    }
    // try to determine mime type by using unix file command
    // this should not be executed on windows
    if (!valid_src_mime_type($mime_type) && !eregi('windows', php_uname())) {
        if (preg_match("/freebsd|linux/", $os)) {
            $mime_type = trim(@shell_exec('file -bi $file'));
        }
    }
    // use file's extension to determine mime type
    if (!valid_src_mime_type($mime_type)) {
        $frags = split("\\.", $file);
        $ext = strtolower($frags[count($frags) - 1]);
        $types = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif');
        if (strlen($ext) && strlen($types[$ext])) {
            $mime_type = $types[$ext];
        }
        // if no extension provided, default to jpg
        if (!strlen($ext) && !valid_src_mime_type($mime_type)) {
            $mime_type = 'image/jpeg';
        }
    }
    return $mime_type;
}
开发者ID:enetter,项目名称:Arthemia-fr,代码行数:32,代码来源:timthumb.php


示例3: mime_type

function mime_type($file)
{
    $os = strtolower(php_uname());
    $mime_type = '';
    // use PECL fileinfo to determine mime type
    if (function_exists('finfo_open')) {
        $finfo = finfo_open(FILEINFO_MIME);
        $mime_type = finfo_file($finfo, $file);
        finfo_close($finfo);
    }
    // try to determine mime type by using unix file command
    // this should not be executed on windows
    if (!valid_src_mime_type($mime_type) && !eregi('windows', $os)) {
        if (preg_match("/freebsd|linux/", $os)) {
            $mime_type = trim(@shell_exec('file -bi $file'));
        }
    }
    // use file's extension to determine mime type
    if (!valid_src_mime_type($mime_type)) {
        // set defaults
        $mime_type = 'image/jpeg';
        // file details
        $fileDetails = pathinfo($file);
        $ext = strtolower($fileDetails["extension"]);
        // mime types
        $types = array('jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'png' => 'image/png', 'gif' => 'image/gif');
        if (strlen($ext) && strlen($types[$ext])) {
            $mime_type = $types[$ext];
        }
    }
    return $mime_type;
}
开发者ID:aufumy,项目名称:falkner-sky,代码行数:32,代码来源:timthumb.php


示例4: list

list($img, $thumb_w, $thumb_h, $t_quality, $nonce) = explode('|', $data);
// validate passed data not tampered with
$data = $img . '|' . $thumb_w . '|' . $thumb_h . '|' . $t_quality;
$FUNCS->validate_nonce('jcrop_image_' . $data, $nonce);
$img = base64_decode($img);
if (extension_loaded('gd') && function_exists('gd_info')) {
    $src = $Config['UserFilesAbsolutePath'] . 'image/' . $img;
    if (file_exists($src)) {
        // create thumbnail
        // Adapted from TimThumb script created by Tim McDaniels and Darren Hoyt with tweaks by Ben Gillbanks
        // http://code.google.com/p/timthumb/
        ini_set('memory_limit', "64M");
        // get mime type of src
        $mime_type = mime_type($src);
        // make sure that the src is gif/jpg/png
        if (!valid_src_mime_type($mime_type)) {
            die("Invalid src mime type: " . $mime_type);
        }
        // open the existing image
        $image = open_image($mime_type, $src);
        if ($image === false) {
            die('Unable to open image : ' . $src);
        }
        // fabricate thumbnail name
        $path_parts = $FUNCS->pathinfo($src);
        if (!$thumb_w || !$thumb_h) {
            // freeform selection
            // dimensions of the thumbnail will be taken from the selected area of src
            $thumb_w = $img_w;
            $thumb_h = $img_h;
            // name of the thumbnail will, however, contain the original width and height of src (to match the name given by core 'thumbnail' editable region)
开发者ID:bartonsweb,项目名称:Couch,代码行数:31,代码来源:ajax.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP valid_str函数代码示例发布时间:2022-05-23
下一篇:
PHP valid_request函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap