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


PHP UploadFile::realpath方法代码示例

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


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

示例1: getUploadRelativeName

/**
 * Helper function for upgrade - get path from upload:// name
 * @param string $path
 * return string
 */
function getUploadRelativeName($path)
{
    if (class_exists('UploadFile')) {
        return UploadFile::realpath($path);
    }
    if (substr($path, 0, 9) == "upload://") {
        $path = rtrim($GLOBALS['sugar_config']['upload_dir'], "/\\") . "/" . substr($path, 9);
    }
    return $path;
}
开发者ID:omusico,项目名称:sugar_work,代码行数:15,代码来源:uw_utils.php

示例2: getProcessImage

 public function getProcessImage($api, $args)
 {
     $path = 'upload://tmp/';
     $image = new PMSEImageGenerator();
     $img = $image->get_image($args['record']);
     $file = new UploadStream();
     if (!$file->checkDir($path)) {
         $file->createDir($path);
     }
     $file_path = UploadFile::realpath($path) . '/' . $args['record'];
     imagepng($img, $file_path);
     imagedestroy($img);
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:13,代码来源:PMSEImageGeneratorApi.php

示例3: urldecode

require_once 'modules/MailMerge/MailMerge.php';
global $beanList, $beanFiles;
$module = $_POST['mailmerge_module'];
$document_id = $_POST['document_id'];
$selObjs = urldecode($_POST['selected_objects_def']);
$item_ids = array();
parse_str($selObjs, $item_ids);
$class_name = $beanList[$module];
$includedir = $beanFiles[$class_name];
require_once $includedir;
$seed = new $class_name();
$fields = get_field_list($seed);
$document = new Document();
$document->retrieve($document_id);
$items = array();
foreach ($item_ids as $key => $value) {
    $seed->retrieve($key);
    $items[] = $seed;
}
ini_set('max_execution_time', 600);
ini_set('error_reporting', 'E_ALL');
$dataDir = create_cache_directory("MergedDocuments/");
$fileName = UploadFile::realpath("upload://{$document->document_revision_id}");
$outfile = pathinfo($document->filename, PATHINFO_FILENAME);
$mm = new MailMerge(null, null, $dataDir);
$mm->SetDataList($items);
$mm->SetFieldList($fields);
$mm->Template(array($fileName, $outfile));
$file = $mm->Execute();
$mm->CleanUp();
header("Location: index.php?module=MailMerge&action=Step4&file=" . urlencode($file));
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:31,代码来源:Save.php

示例4: zip_files_list

/**
 * Zip list of files, optionally stripping prefix
 * FIXME: check what happens with streams
 * @param string $zip_file
 * @param array $file_list
 * @param string $prefix Regular expression for the prefix to strip
 */
function zip_files_list($zip_file, $file_list, $prefix = '')
{
    $archive = new ZipArchive();
    $res = $archive->open(UploadFile::realpath($zip_file), ZipArchive::CREATE | ZipArchive::OVERWRITE);
    // we need realpath here for PHP streams support
    if ($res !== TRUE) {
        $GLOBALS['log']->fatal("Unable to open zip file, check directory permissions: {$zip_file}");
        return FALSE;
    }
    foreach ($file_list as $file) {
        if (!empty($prefix) && preg_match($prefix, $file, $matches) > 0) {
            $zipname = substr($file, strlen($matches[0]));
        } else {
            $zipname = $file;
        }
        $archive->addFile($file, $zipname);
    }
    return TRUE;
}
开发者ID:omusico,项目名称:sugar_work,代码行数:26,代码来源:php_zip_utils.php

示例5: 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


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