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

PHP ext2mime函数代码示例

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

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



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

示例1: returnFile

function returnFile($in, $out, $ext)
{
    header("Pragma: public");
    header("Content-type: " . ext2mime($ext));
    header('Content-Disposition: ' . ($ext == 'pdf' ? 'inline' : 'attachment') . '; filename="' . addslashes($out) . '"');
    if (is_file($in)) {
        header('Content-Length: ' . filesize($in));
        readfile($in);
    } else {
        header('Content-Length: ' . strlen($in));
        echo $in;
    }
}
开发者ID:mehulsbhatt,项目名称:PHP-Scanner-Server,代码行数:13,代码来源:download.php


示例2: email2GetMime

 /**
  * Determines MIME-type encoding as possible.
  * @param string $fileLocation relative path to file
  * @return string MIME-type
  */
 function email2GetMime($fileLocation)
 {
     if (!is_readable($fileLocation)) {
         return 'application/octet-stream';
     }
     if (function_exists('mime_content_type')) {
         $mime = mime_content_type($fileLocation);
     } elseif (function_exists('ext2mime')) {
         $mime = ext2mime($fileLocation);
     } else {
         $mime = 'application/octet-stream';
     }
     return $mime;
 }
开发者ID:rgauss,项目名称:sugarcrm_dev,代码行数:19,代码来源:Email.php


示例3: getMime

 /**
  * Get MIME type for uploaded file
  * @param array $_FILES_element $_FILES element required
  * @return string MIME type
  */
 function getMime($_FILES_element)
 {
     $filename = $_FILES_element['name'];
     $file_ext = pathinfo($filename, PATHINFO_EXTENSION);
     //If no file extension is available and the mime is octet-stream try to determine the mime type.
     $recheckMime = empty($file_ext) && !empty($_FILES_element['type']) && $_FILES_element['type'] == 'application/octet-stream';
     if (!empty($_FILES_element['type']) && !$recheckMime) {
         $mime = $_FILES_element['type'];
     } elseif (function_exists('mime_content_type')) {
         $mime = mime_content_type($_FILES_element['tmp_name']);
     } elseif (function_exists('ext2mime')) {
         $mime = ext2mime($_FILES_element['name']);
     } else {
         $mime = 'application/octet-stream';
     }
     return $mime;
 }
开发者ID:sunmo,项目名称:snowlotus,代码行数:22,代码来源:upload_file.php


示例4: getMime

 /**
  * Get MIME type for uploaded file
  * @param array $_FILES_element $_FILES element required
  * @return string MIME type
  */
 function getMime($_FILES_element)
 {
     $filename = $_FILES_element['name'];
     $filetype = isset($_FILES_element['type']) ? $_FILES_element['type'] : null;
     $file_ext = pathinfo($filename, PATHINFO_EXTENSION);
     $is_image = strpos($filetype, 'image/') === 0;
     // if it's an image, or no file extension is available and the mime is octet-stream
     // try to determine the mime type
     $recheckMime = $is_image || empty($file_ext) && $filetype == 'application/octet-stream';
     $mime = 'application/octet-stream';
     if ($filetype && !$recheckMime) {
         $mime = $filetype;
     } elseif (function_exists('mime_content_type')) {
         $mime = mime_content_type($_FILES_element['tmp_name']);
     } elseif ($is_image) {
         $info = getimagesize($_FILES_element['tmp_name']);
         if ($info) {
             $mime = $info['mime'];
         }
     } elseif (function_exists('ext2mime')) {
         $mime = ext2mime($filename);
     }
     return $mime;
 }
开发者ID:anmoldeep,项目名称:erp,代码行数:29,代码来源:upload_file.php


示例5: getMimeType

 /**
  * Get mime types of file if function mime_content_type dont exist or not recognize type
  * @param string $filename
  * @return string
  * 	return mime type of file
  */
 public static function getMimeType($filename)
 {
     if (function_exists('mime_content_type')) {
         $mime = mime_content_type($filename);
     } elseif (function_exists('ext2mime')) {
         $mime = ext2mime($filename);
     }
     if (empty($mime)) {
         $ext = strtolower(array_pop(explode('.', $filename)));
         if (array_key_exists($ext, self::$extMimeTypes)) {
             $mime = self::$extMimeTypes[$ext];
         } else {
             $mime = 'application/octet-stream';
         }
     }
     return $mime;
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:23,代码来源:Utils.php


示例6: getMime

 function getMime(&$_FILES_element)
 {
     $filename = $_FILES_element['name'];
     if ($_FILES_element['type']) {
         $mime = $_FILES_element['type'];
     } elseif (function_exists('mime_content_type')) {
         $mime = mime_content_type($_FILES_element['tmp_name']);
     } elseif (function_exists('ext2mime')) {
         $mime = ext2mime($_FILES_element['name']);
     } else {
         $mime = ' application/octet-stream';
     }
     return $mime;
 }
开发者ID:nerdystudmuffin,项目名称:dashlet-subpanels,代码行数:14,代码来源:upload_file.php


示例7: get_file_mime_type

/**
 * Attempts to use PHPs mime type getters, where available, to get the content
 * type of a file. Checks existence of the file
 *
 * @param string $file The filepath to get the mime type for
 * @param string $default An optional mimetype string to return if one cannot be found
 * @return string The string content type of the file or false if the file does
 *                not exist
 */
function get_file_mime_type($file, $default = false)
{
    // If the file is readable then use it
    if (is_readable($file)) {
        $file = UploadFile::realpath($file);
        // Default the return
        $mime = '';
        // Check first for the finfo functions needed to use built in functions
        // Suppressing warnings since some versions of PHP are choking on
        // getting the mime type by reading the file contents even though the
        // file is readable
        if (mime_is_detectable_by_finfo()) {
            $finfo = finfo_open(FILEINFO_MIME_TYPE);
            if ($finfo) {
                $mime = @finfo_file($finfo, $file);
                finfo_close($finfo);
            }
        } else {
            // Fall back to our regular way of doing it
            if (function_exists('mime_content_type')) {
                $mime = @mime_content_type($file);
            } elseif (function_exists('ext2mime')) {
                $mime = @ext2mime($file);
            }
        }
        // If mime is empty, set it manually... this can happen from either not
        // being able to detect the mime type using core PHP functions or in the
        // case of a failure of one of the core PHP functions for some reason
        if (empty($mime)) {
            $mime = 'application/octet-stream';
        }
        return $mime;
    }
    return $default;
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:44,代码来源:file_utils.php


示例8: set_file_attachment

function set_file_attachment($session, $file)
{
    global $db;
    require_once 'soap/config_upload.php';
    // require_once ('base.php');
    $error = new SoapError();
    if (!validate_authenticated($session)) {
        $error->set_error('invalid_login');
        return array('id' => -1, 'error' => $error->get_soap_array());
    }
    $AppUI =& $_SESSION['AppUI'];
    $GLOBALS['AppUI'] = $AppUI;
    $module_name = 'files';
    $perms =& $AppUI->acl();
    $canAccess = $perms->checkModule($module_name, 'access');
    $canAuthor = $perms->checkModule($module_name, 'add');
    $GLOBALS['perms'] = $perms;
    if (!$canAccess || !$canAuthor) {
        $error->set_error('no_access');
        return array('id' => -1, 'error' => $error->get_soap_array());
    }
    $modclass = $AppUI->getModuleClass($module_name);
    if (file_exists($modclass)) {
        include_once $modclass;
    } else {
        $error->set_error('no_module');
        return array('id' => -1, 'error' => $error->get_soap_array());
    }
    $module_name = 'tasks';
    $modclass = $AppUI->getModuleClass($module_name);
    if (file_exists($modclass)) {
        include_once $modclass;
    } else {
        $error->set_error('no_module');
        return array('id' => -1, 'error' => $error->get_soap_array());
    }
    $focus = new CFile();
    $task = new CTask();
    $task->load($file['task_id']);
    /// $error->description.=$file['location'];
    //$file['location'] = base64_decode($file['location']);
    //$file['filename'] = base64_decode($file['filename']);
    /*if (filesize($file['location'] > $config_upload['upload_maxsize']){
         $error->set_error('no_file');
         return array('id'=>-1, 'error'=>$error->get_soap_array());
      }*/
    $file_real_filename = uniqid(rand());
    $new_location = DP_BASE_DIR . '/files/' . $task->task_project . '/' . $file_real_filename;
    /// $error->description.=$new_location;
    if (!is_dir(DP_BASE_DIR . '/files/' . $task->task_project)) {
        mkdir(DP_BASE_DIR . '/files/' . $task->task_project);
    }
    copy($file['location'], $new_location);
    if (file_exists($new_location)) {
        //  return array('id'=>$new_location, 'error'=>$error->get_soap_array());
        if (!empty($file['filename'])) {
            $upload_filename = $file['filename'];
            $ext_pos = strrpos($upload_filename, ".");
            $file_ext = substr($upload_filename, $ext_pos + 1);
            // $error->description.="file_ext: ".$file_ext;
            // return array('id'=>-1, 'error'=>$error->get_soap_array());
            /* if (in_array($file_ext, $config_upload['upload_badext'])) {
                  $upload_filename .= ".txt";
                  $file_ext = "txt";
               }*/
            $focus->file_name = $upload_filename;
            $focus->file_owner = $AppUI->user_id;
            // $error->description.="file_owner_id: ".$AppUI->user_id;
            $focus->file_real_filename = $file_real_filename;
            $focus->file_project = $task->task_project;
            $focus->file_date = str_replace("'", '', $db->DBTimeStamp(time()));
            // $error->description.="file_task_id: ".$task->task_id;
            $focus->file_task = $task->task_id;
            $focus->file_folder = 0;
            $focus->file_size = filesize($new_location);
            $focus->file_parent = 0;
            $focus->file_folder = 0;
            $focus->file_version = 1;
            $focus->file_version_id = getNextVersionID();
            $focus->file_category = 1;
            $focus->file_type = ext2mime($file_ext);
            $focus->store();
            //  $error->description.="file_file: ".$focus->file_type;
        } else {
            $error->set_error('no_file');
            return array('id' => -1, 'error' => $error->get_soap_array());
        }
    } else {
        $error->set_error('no_file');
        return array('id' => -1, 'error' => $error->get_soap_array());
    }
    return array('id' => $focus->file_id, 'error' => $error->get_soap_array());
}
开发者ID:EvgenyPopov,项目名称:DotProject-SOAP,代码行数:93,代码来源:SoapFunctions.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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