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

PHP pathinfo函数代码示例

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

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



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

示例1: resize

 public function resize($filename, $width, $height)
 {
     if (!file_exists(DIR_IMAGE . $filename) || !is_file(DIR_IMAGE . $filename)) {
         return;
     }
     $info = pathinfo($filename);
     $extension = $info['extension'];
     $old_image = $filename;
     $new_image = 'cache/' . utf8_substr($filename, 0, utf8_strrpos($filename, '.')) . '-' . $width . 'x' . $height . '.' . $extension;
     if (!file_exists(DIR_IMAGE . $new_image) || filemtime(DIR_IMAGE . $old_image) > filemtime(DIR_IMAGE . $new_image)) {
         $path = '';
         $directories = explode('/', dirname(str_replace('../', '', $new_image)));
         foreach ($directories as $directory) {
             $path = $path . '/' . $directory;
             if (!file_exists(DIR_IMAGE . $path)) {
                 @mkdir(DIR_IMAGE . $path, 0777);
             }
         }
         $image = new Image(DIR_IMAGE . $old_image);
         $image->resize($width, $height);
         $image->save(DIR_IMAGE . $new_image);
     }
     if (isset($this->request->server['HTTPS']) && ($this->request->server['HTTPS'] == 'on' || $this->request->server['HTTPS'] == '1')) {
         return HTTPS_CATALOG . 'image/' . $new_image;
     } else {
         return HTTP_CATALOG . 'image/' . $new_image;
     }
 }
开发者ID:gittrue,项目名称:VIF,代码行数:28,代码来源:image.php


示例2: __construct

 /**
  * Tests that the storage location is a directory and is writable.
  */
 public function __construct($filename)
 {
     // Get the directory name
     $directory = str_replace('\\', '/', realpath(pathinfo($filename, PATHINFO_DIRNAME))) . '/';
     // Set the filename from the real directory path
     $filename = $directory . basename($filename);
     // Make sure the cache directory is writable
     if (!is_dir($directory) or !is_writable($directory)) {
         throw new KoException('Cache: Directory :name is unwritable.', array(':name' => $directory));
     }
     // Make sure the cache database is writable
     if (is_file($filename) and !is_writable($filename)) {
         throw new KoException('Cache: File :name is unwritable.', array(':name' => $filename));
     }
     // Open up an instance of the database
     $this->db = new SQLiteDatabase($filename, '0666', $error);
     // Throw an exception if there's an error
     if (!empty($error)) {
         throw new KoException('Cache: Driver error - ' . sqlite_error_string($error));
     }
     $query = "SELECT name FROM sqlite_master WHERE type = 'table' AND name = 'caches'";
     $tables = $this->db->query($query, SQLITE_BOTH, $error);
     // Throw an exception if there's an error
     if (!empty($error)) {
         throw new KoException('Cache: Driver error - ' . sqlite_error_string($error));
     }
     if ($tables->numRows() == 0) {
         // Issue a CREATE TABLE command
         $this->db->unbufferedQuery('CREATE TABLE caches(id VARCHAR(127) PRIMARY KEY, expiration INTEGER, cache TEXT);');
     }
 }
开发者ID:atlas1308,项目名称:testtesttestfarm,代码行数:34,代码来源:sqlite.php


示例3: pic_cutOp

 /**
  * 图片裁剪
  *
  */
 public function pic_cutOp()
 {
     Uk86Language::uk86_read('admin_common');
     $lang = Uk86Language::uk86_getLangContent();
     uk86_import('function.thumb');
     if (uk86_chksubmit()) {
         $thumb_width = $_POST['x'];
         $x1 = $_POST["x1"];
         $y1 = $_POST["y1"];
         $x2 = $_POST["x2"];
         $y2 = $_POST["y2"];
         $w = $_POST["w"];
         $h = $_POST["h"];
         $scale = $thumb_width / $w;
         $src = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['url']);
         if (strpos($src, '..') !== false || strpos($src, BASE_UPLOAD_PATH) !== 0) {
             exit;
         }
         if (!empty($_POST['filename'])) {
             // 				$save_file2 = BASE_UPLOAD_PATH.'/'.$_POST['filename'];
             $save_file2 = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_POST['filename']);
         } else {
             $save_file2 = str_replace('_small.', '_sm.', $src);
         }
         $cropped = uk86_resize_thumb($save_file2, $src, $w, $h, $x1, $y1, $scale);
         @unlink($src);
         $pathinfo = pathinfo($save_file2);
         exit($pathinfo['basename']);
     }
     $save_file = str_ireplace(UPLOAD_SITE_URL, BASE_UPLOAD_PATH, $_GET['url']);
     $_GET['resize'] = $_GET['resize'] == '0' ? '0' : '1';
     Tpl::output('height', uk86_get_height($save_file));
     Tpl::output('width', uk86_get_width($save_file));
     Tpl::showpage('common.pic_cut', 'null_layout');
 }
开发者ID:wangjiang988,项目名称:ukshop,代码行数:39,代码来源:common.php


示例4: openseadragon

 /**
  * Return a OpenSeadragon image viewer for the provided files.
  * 
  * @param File|array $files A File record or an array of File records.
  * @param int $width The width of the image viewer in pixels.
  * @param int $height The height of the image viewer in pixels.
  * @return string|null
  */
 public function openseadragon($files)
 {
     if (!is_array($files)) {
         $files = array($files);
     }
     // Filter out invalid images.
     $images = array();
     $imageNames = array();
     foreach ($files as $file) {
         // A valid image must be a File record.
         if (!$file instanceof File) {
             continue;
         }
         // A valid image must have a supported extension.
         $extension = pathinfo($file->original_filename, PATHINFO_EXTENSION);
         if (!in_array(strtolower($extension), $this->_supportedExtensions)) {
             continue;
         }
         $images[] = $file;
         $imageNames[explode(".", $file->filename)[0]] = openseadragon_dimensions($file, 'original');
     }
     // Return if there are no valid images.
     if (!$images) {
         return;
     }
     return $this->view->partial('common/openseadragon.php', array('images' => $images, 'imageNames' => $imageNames));
 }
开发者ID:UVicLibrary,项目名称:omeka-OpenSeadragon2,代码行数:35,代码来源:Openseadragon.php


示例5: getUpgrades

 /**
  * Returns an array of all possible upgrade files as an array with
  * the upgrade's key and version
  * 
  * This first looks for all .php files in the versions directory.
  * The files should have the format of VERSION_NUMBER (e.g. 1.0.0__1).
  * The project is then checked to see if 
  */
 public function getUpgrades()
 {
     if (!$this->_upgrades) {
         $this->_upgrades = array();
         $versions = array();
         $dir = dirname(__FILE__) . '/versions';
         $files = sfFinder::type('file')->name('*.php')->in($dir);
         foreach ($files as $file) {
             $info = pathinfo($file);
             if (strpos($info['filename'], '__') === false) {
                 throw new sfException(sprintf('Invalid upgrade filename format for file "%s" - must contain a double underscore - VERSION__NUMBER (e.g. 1.0.0__1) ', $info['filename']));
             }
             $e = explode('__', $info['filename']);
             $version = $e[0];
             $number = $e[1];
             if ($this->_isVersionNew($info['filename'])) {
                 $versions[] = array('version' => $version, 'number' => $number);
                 $this->_upgrades[] = $version . '__' . $number;
             }
         }
         natcasesort($this->_upgrades);
         foreach ($this->_upgrades as $key => $version) {
             $this->_upgrades[$key] = $versions[$key];
         }
     }
     return $this->_upgrades;
 }
开发者ID:sympal,项目名称:sympal,代码行数:35,代码来源:sfSympalProjectUpgrade.class.php


示例6: getUrlUploadMultiImages

 public static function getUrlUploadMultiImages($obj, $user_id)
 {
     $url_arr = array();
     $min_size = 1024 * 1000 * 700;
     $max_size = 1024 * 1000 * 1000 * 3.5;
     foreach ($obj["tmp_name"] as $key => $tmp_name) {
         $ext_arr = array('png', 'jpg', 'jpeg', 'bmp');
         $name = StringHelper::filterString($obj['name'][$key]);
         $storeFolder = Yii::getPathOfAlias('webroot') . '/images/' . date('Y-m-d', time()) . '/' . $user_id . '/';
         $pathUrl = 'images/' . date('Y-m-d', time()) . '/' . $user_id . '/' . time() . $name;
         if (!file_exists($storeFolder)) {
             mkdir($storeFolder, 0777, true);
         }
         $tempFile = $obj['tmp_name'][$key];
         $targetFile = $storeFolder . time() . $name;
         $ext = strtolower(pathinfo($name, PATHINFO_EXTENSION));
         $size = $obj['name']['size'];
         if (in_array($ext, $ext_arr)) {
             if ($size >= $min_size && $size <= $max_size) {
                 if (move_uploaded_file($tempFile, $targetFile)) {
                     array_push($url_arr, $pathUrl);
                 } else {
                     return NULL;
                 }
             } else {
                 return NULL;
             }
         } else {
             return NULL;
         }
     }
     return $url_arr;
 }
开发者ID:huynt57,项目名称:image_chooser,代码行数:33,代码来源:UploadHelper.php


示例7: pic_thumb

 function pic_thumb($pic_id)
 {
     $this->load->helper('file');
     $this->load->library('image_lib');
     $base_path = "uploads/item_pics/" . $pic_id;
     $images = glob($base_path . "*");
     if (sizeof($images) > 0) {
         $image_path = $images[0];
         $ext = pathinfo($image_path, PATHINFO_EXTENSION);
         $thumb_path = $base_path . $this->image_lib->thumb_marker . '.' . $ext;
         if (sizeof($images) < 2) {
             $config['image_library'] = 'gd2';
             $config['source_image'] = $image_path;
             $config['maintain_ratio'] = TRUE;
             $config['create_thumb'] = TRUE;
             $config['width'] = 52;
             $config['height'] = 32;
             $this->image_lib->initialize($config);
             $image = $this->image_lib->resize();
             $thumb_path = $this->image_lib->full_dst_path;
         }
         $this->output->set_content_type(get_mime_by_extension($thumb_path));
         $this->output->set_output(file_get_contents($thumb_path));
     }
 }
开发者ID:Exactpk,项目名称:opensourcepos,代码行数:25,代码来源:items.php


示例8: getImageFileType

 public function getImageFileType($file)
 {
     $type = '';
     // default type
     $imgfile = explode('?', $file);
     $fileinfo = pathinfo($imgfile[0]);
     if (!isset($fileinfo['extension']) || !$fileinfo['extension']) {
         $fileinfo['extension'] = 'php';
     }
     $type = strtolower($fileinfo['extension']);
     if ($type == 'cgi') {
         $type = 'php';
     }
     if ($type == 'jpg') {
         $type = 'jpeg';
     }
     if ($type == 'php') {
         // identification des infos
         $infos = @GetImageSize($file);
         if (!$infos) {
             $this->Error('Unsupported image : ' . $file);
         }
         // identification du type
         $type = explode('/', $infos['mime']);
         if ($type[0] != 'image') {
             $this->Error('Unsupported image : ' . $file);
         }
         $type = $type[1];
     }
     return $type;
 }
开发者ID:jhbsz,项目名称:ossimTest,代码行数:31,代码来源:mypdf.class.php


示例9: exploreDir

function exploreDir($dirname, $keyword)
{
    $allowedExt = ".php.pdf.chm";
    $dh = opendir($dirname);
    while ($file = readdir($dh)) {
        if (is_dir("{$dirname}/{$file}")) {
            if ($file != '.' and $file != '..') {
                exploreDir("{$dirname}/{$file}", $keyword);
            }
        } else {
            if ($file == 'index.php') {
                $file = basename($dirname);
                if (ereg($keyword, $file)) {
                    echo '<a href="', $dirname, '">', $file, '</a><br>';
                }
            } else {
                if (ereg($keyword, $file)) {
                    $ext = pathinfo($file, PATHINFO_EXTENSION);
                    $ext = ".{$ext}";
                    if (ereg($ext, $allowedExt)) {
                        echo '<a href="', $dirname, '/', $file, '">', basename($file, $ext), '</a><br>';
                    }
                }
            }
        }
    }
    closedir($dh);
}
开发者ID:yczhangsjtu,项目名称:html,代码行数:28,代码来源:search.php


示例10: isWritable

 function isWritable($sFile, $sPrePath = '/../../')
 {
     clearstatcache();
     $aPathInfo = pathinfo(__FILE__);
     $sFile = $aPathInfo['dirname'] . '/../../' . $sFile;
     return is_readable($sFile) && is_writable($sFile);
 }
开发者ID:Gotgot59,项目名称:dolphin.pro,代码行数:7,代码来源:BxDolIO.php


示例11: preSave

 /**
  * Handle pre save event
  *
  * @param LifecycleEventArgs $args Event arguments
  */
 protected function preSave(LifecycleEventArgs $args)
 {
     $annotations = $this->container->get('cyber_app.metadata.reader')->getUploadebleFieldsAnnotations($args->getEntity());
     if (0 === count($annotations)) {
         return;
     }
     foreach ($annotations as $field => $annotation) {
         $config = $this->container->getParameter('oneup_uploader.config.' . $annotation->endpoint);
         if (!(isset($config['use_orphanage']) && $config['use_orphanage'])) {
             continue;
         }
         $value = (array) PropertyAccess::createPropertyAccessor()->getValue($args->getEntity(), $field);
         $value = array_filter($value, 'strlen');
         $value = array_map(function ($file) {
             return pathinfo($file, PATHINFO_BASENAME);
         }, $value);
         if (empty($value)) {
             continue;
         }
         $orphanageStorage = $this->container->get('oneup_uploader.orphanage.' . $annotation->endpoint);
         $files = [];
         foreach ($orphanageStorage->getFiles() as $file) {
             if (in_array($file->getBasename(), $value, true)) {
                 $files[] = $file;
             }
         }
         $orphanageStorage->uploadFiles($files);
     }
 }
开发者ID:snovichkov,项目名称:UploaderBundle,代码行数:34,代码来源:UploadListener.php


示例12: uploadFile

 /**
  * Uploads a XLS file with all attribute texts.
  *
  * @param \stdClass $params Object containing the properties
  */
 public function uploadFile(\stdClass $params)
 {
     $this->checkParams($params, array('site'));
     $this->setLocale($params->site);
     if (($fileinfo = reset($_FILES)) === false) {
         throw new \Aimeos\Controller\ExtJS\Exception('No file was uploaded');
     }
     $config = $this->getContext()->getConfig();
     /** controller/extjs/attribute/import/text/standard/enablecheck
      * Enables checking uploaded files if they are valid and not part of an attack
      *
      * This configuration option is for unit testing only! Please don't disable
      * the checks for uploaded files in production environments as this
      * would give attackers the possibility to infiltrate your installation!
      *
      * @param boolean True to enable, false to disable
      * @since 2014.03
      * @category Developer
      */
     if ($config->get('controller/extjs/attribute/import/text/standard/enablecheck', true)) {
         $this->checkFileUpload($fileinfo['tmp_name'], $fileinfo['error']);
     }
     $fileext = pathinfo($fileinfo['name'], PATHINFO_EXTENSION);
     $dest = md5($fileinfo['name'] . time() . getmypid()) . '.' . $fileext;
     $fs = $this->getContext()->getFilesystemManager()->get('fs-admin');
     $fs->writef($dest, $fileinfo['tmp_name']);
     $result = (object) array('site' => $params->site, 'items' => array((object) array('job.label' => 'Attribute text import: ' . $fileinfo['name'], 'job.method' => 'Attribute_Import_Text.importFile', 'job.parameter' => array('site' => $params->site, 'items' => $dest), 'job.status' => 1)));
     $jobController = \Aimeos\Controller\ExtJS\Admin\Job\Factory::createController($this->getContext());
     $jobController->saveItems($result);
     return array('items' => $dest, 'success' => true);
 }
开发者ID:mvnp,项目名称:aimeos-core,代码行数:36,代码来源:Standard.php


示例13: iteratorFilter

	public function iteratorFilter($path)
	{
        $state     = $this->getState();
		$filename  = ltrim(basename(' '.strtr($path, array('/' => '/ '))));
		$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));

		if ($state->name)
        {
			if (!in_array($filename, (array) $state->name)) {
				return false;
			}
		}

		if ($state->types)
        {
			if ((in_array($extension, ComFilesModelEntityFile::$image_extensions) && !in_array('image', (array) $state->types))
			|| (!in_array($extension, ComFilesModelEntityFile::$image_extensions) && !in_array('file', (array) $state->types))
			) {
				return false;
			}
		}

		if ($state->search && stripos($filename, $state->search) === false) {
            return false;
        }
	}
开发者ID:kosmosby,项目名称:medicine-prof,代码行数:26,代码来源:files.php


示例14: addView

 /**
  * Add a View instance to the Collector
  *
  * @param \Illuminate\View\View $view
  */
 public function addView(View $view)
 {
     $name = $view->getName();
     $path = $view->getPath();
     if (!is_object($path)) {
         if ($path) {
             $path = ltrim(str_replace(base_path(), '', realpath($path)), '/');
         }
         if (substr($path, -10) == '.blade.php') {
             $type = 'blade';
         } else {
             $type = pathinfo($path, PATHINFO_EXTENSION);
         }
     } else {
         $type = get_class($view);
         $path = '';
     }
     if (!$this->collect_data) {
         $params = array_keys($view->getData());
     } else {
         $data = array();
         foreach ($view->getData() as $key => $value) {
             $data[$key] = $this->exporter->exportValue($value);
         }
         $params = $data;
     }
     $this->templates[] = array('name' => $path ? sprintf('%s (%s)', $name, $path) : $name, 'param_count' => count($params), 'params' => $params, 'type' => $type);
 }
开发者ID:drickferreira,项目名称:rastreador,代码行数:33,代码来源:ViewCollector.php


示例15: add

 function add($file, $appname, $user, $name, $size)
 {
     $info = pathinfo($name);
     /*if (empty ($name)) {
     			$name = $info['basename'];
     		} elseif (! strstr ($name, $info['extension'])) {
     			$name = $name . '.' . $info['extension'];
     		}*/
     $struct = array('name' => $user, 'file' => $name, 'type' => $this->getType($info['extension']), 'size' => $size, 'appname' => $appname);
     // move file
     if ($this->store->exists($appname . '-' . $name)) {
         $this->error = 'File already exists!  Please choose another name';
         return false;
     }
     if (!$this->store->move($appname . '-' . $name, $file, true)) {
         $this->error = $this->store->error;
         return false;
     }
     // add to database
     $res = parent::add($struct);
     if (!$res) {
         return false;
     }
     return $this->getPath($name, $appname);
 }
开发者ID:vojtajina,项目名称:sitellite,代码行数:25,代码来源:Files.php


示例16: register

 /**
  * Register mwEmbeed resource set 
  * 
  * Adds modules to ResourceLoader
  */
 public static function register($mwEmbedResourcePath)
 {
     global $IP, $wgExtensionMessagesFiles;
     $fullResourcePath = $IP . '/' . $mwEmbedResourcePath;
     // Get the module name from the end of the path:
     $modulePathParts = explode('/', $mwEmbedResourcePath);
     $moduleName = array_pop($modulePathParts);
     if (!is_dir($fullResourcePath)) {
         throw new MWException(__METHOD__ . " not given readable path: " . htmlspecialchars($mwEmbedResourcePath));
     }
     if (substr($mwEmbedResourcePath, -1) == '/') {
         throw new MWException(__METHOD__ . " path has trailing slash: " . htmlspecialchars($mwEmbedResourcePath));
     }
     // Add module messages if present:
     $msgFileName = $fullResourcePath . '/' . $moduleName . '.i18n';
     if (is_file($msgFileName . '.json')) {
         $wgExtensionMessagesFiles['MwEmbed.' . $moduleName] = $msgFileName . '.json';
     } elseif (is_file($msgFileName . '.php')) {
         $wgExtensionMessagesFiles['MwEmbed.' . $moduleName] = $msgFileName . '.php';
     }
     // Get the mwEmbed module resource registration:
     $moduleResourceFileName = $fullResourcePath . '/' . $moduleName;
     if (is_file($moduleResourceFileName . '.json')) {
         $resourceList = json_decode(file_get_contents($moduleResourceFileName . '.json'), TRUE);
     } else {
         $resourceList = (include $moduleResourceFileName . '.php');
     }
     // Look for special 'messages' => 'moduleFile' key and load all modules file messages:
     foreach ($resourceList as $name => $resources) {
         if (isset($resources['messageFile']) && is_file($fullResourcePath . '/' . $resources['messageFile'])) {
             $resourceList[$name]['messages'] = array();
             $ext = pathinfo($fullResourcePath . '/' . $resources['messageFile'], PATHINFO_EXTENSION);
             switch ($ext) {
                 case "json":
                     $messages = json_decode(file_get_contents($fullResourcePath . '/' . $resources['messageFile']), TRUE);
                     break;
                 case "php":
                     include $fullResourcePath . '/' . $resources['messageFile'];
                     break;
             }
             foreach ($messages['en'] as $msgKey => $na) {
                 $resourceList[$name]['messages'][] = $msgKey;
             }
         }
     }
     // Check for module loader:
     if (is_file($fullResourcePath . '/' . $moduleName . '.loader.js')) {
         $resourceList[$moduleName . '.loader'] = array('loaderScripts' => $moduleName . '.loader.js');
     }
     // Check for module config ( @@TODO support per-module config )
     $configPathFileName = $fullResourcePath . '/' . $moduleName . '.config';
     if (is_file($configPathFileName . '.json')) {
         $moduleConfigObj = json_decode(file_get_contents($configPathFileName . '.json'), TRUE);
         self::$moduleConfig = array_merge(self::$moduleConfig, $moduleConfigObj);
     } elseif (is_file($configPathFileName . '.php')) {
         self::$moduleConfig = array_merge(self::$moduleConfig, include $configPathFileName . '.php');
     }
     // Add the resource list into the module set with its provided path
     self::$moduleSet[$mwEmbedResourcePath] = $resourceList;
 }
开发者ID:GrahamDigital,项目名称:mwEmbed,代码行数:65,代码来源:MwEmbedResourceManager.php


示例17: ossn_register_plugins_by_path

/**
 * Register a plugins by path
 * This will help us to override components files easily.
 * 
 * @param string $path A valid path;
 * @return boolean
 */
function ossn_register_plugins_by_path($path)
{
    global $Ossn;
    if (ossn_site_settings('cache') == 1) {
        return false;
    }
    $type = 'default';
    $type = ossn_call_hook('plugins', 'type', false, $type);
    $path = $path . $type . '/';
    if (!is_dir($path)) {
        //disable error log, will cause a huge log file
        //error_log("Ossn tried to register invalid plugins by path: {$path}");
        return false;
    }
    $path = str_replace("\\", "/", $path);
    $directory = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS);
    $iterator = new RecursiveIteratorIterator($directory);
    if ($iterator) {
        foreach ($iterator as $file) {
            if (pathinfo($file, PATHINFO_EXTENSION) == "php") {
                $file = str_replace("\\", "/", $file);
                $location = str_replace(dirname(__FILE__) . '/plugins/', '', $file);
                $name = str_replace($path, '', $location);
                $name = substr($name, 0, -4);
                $fpath = substr($file, 0, -4);
                $fpath = str_replace(array($name, ossn_route()->www), '', $fpath);
                $Ossn->plugins[$name] = $fpath;
            }
        }
    }
    return true;
}
开发者ID:sthefanysoares,项目名称:Social-Network,代码行数:39,代码来源:ossn.lib.plugins.php


示例18: actionCrop

 public function actionCrop($id)
 {
     $model = $this->findModel($id);
     $type = \Yii::$app->getRequest()->post("type");
     $x = \Yii::$app->getRequest()->post("x");
     $y = \Yii::$app->getRequest()->post("y");
     $w = \Yii::$app->getRequest()->post("w");
     $h = \Yii::$app->getRequest()->post("h");
     switch ($type) {
         case CropType::ALL:
             $original = $model->getAbsolutePath();
             Image::crop($original, $w, $h, [$x, $y])->save($original);
             $model->deleteThumbs();
             break;
         case CropType::THUMBNAIL:
             $original = $model->getAbsolutePath();
             $newPath = $model->getTempDirectory() . DIRECTORY_SEPARATOR . $model->hash . "." . $model->extension;
             $newOriginal = \Yii::$app->get("fileStorage")->getPath($newPath);
             Image::crop($original, $w, $h, [$x, $y])->save($newOriginal);
             $thumbs = $model->getThumbs();
             foreach ($thumbs as $path) {
                 $fileName = ltrim(pathinfo(" " . $path, PATHINFO_FILENAME));
                 $parts = explode("_", $fileName);
                 list($w, $h) = explode("x", $parts[2]);
                 Image::thumbnail($newOriginal, $w, $h)->save(\Yii::$app->get("fileStorage")->getPath($path));
             }
             \Yii::$app->get("fileStorage")->delete($newPath);
             break;
         case CropType::ORIGINAL:
             $original = $model->getAbsolutePath();
             Image::crop($original, $w, $h, [$x, $y])->save($original);
             break;
     }
     return $this->renderJsonMessage(true, "裁剪成功");
 }
开发者ID:rocketyang,项目名称:hasscms-app,代码行数:35,代码来源:DefaultController.php


示例19: convert

 public function convert($filename, $filepath)
 {
     $ext = pathinfo($filename, PATHINFO_EXTENSION);
     switch ($ext) {
         case "txt":
             return file_get_contents($filepath);
         case "html":
         case "htm":
             return strip_tags(str_replace(array("<br>", "<div>"), "\n", file_get_contents($filepath)));
             //get rid of all html tags, but keep some linebreaks there.
         //get rid of all html tags, but keep some linebreaks there.
         case "doc":
             return $this->docToText($filepath);
         case "docx":
             return $this->docxToText($filepath);
         case "odt":
             return $this->odtToText($filepath);
         case "pdf":
             return $this->pdfToText($filepath);
             //case "csv"://really awk case. Plus not sanitized. D:
             //DB::query("LOAD DATA INFILE '%0%' INTO TABLE questions FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES",($_FILE["file"]["tmp_name"]));
         //case "csv"://really awk case. Plus not sanitized. D:
         //DB::query("LOAD DATA INFILE '%0%' INTO TABLE questions FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES",($_FILE["file"]["tmp_name"]));
         default:
             echo "Unsupported file extension <i>{$ext}</i> - we currently support txt, html, doc, docx, odt, pdf.";
     }
 }
开发者ID:t-web,项目名称:doeqs_new,代码行数:27,代码来源:class.fileToStr.php


示例20: actionGetfilelist

 public function actionGetfilelist($template)
 {
     $fileutil = new FileUtil();
     $dir = null;
     $loc = $_REQUEST['loc'];
     if ($loc == null) {
         $dir = 'themes/' . $template . '/views';
     } else {
         $dir = $loc;
     }
     $handler = opendir($dir);
     $files = array();
     while (($filename = readdir($handler)) !== false) {
         //务必使用!==,防止目录下出现类似文件名“0”等情况
         $extend = pathinfo($filename);
         $extend = strtolower($extend["extension"]);
         if ($filename != "." && $filename != ".." && $extend !== "db") {
             if (is_dir($dir . '/' . $filename)) {
                 $files[] = array(name => $filename, loc => $dir . '/' . $filename, isParent => true);
             } else {
                 $files[] = array(name => $filename, loc => $dir . '/' . $filename, isParent => false);
             }
         }
     }
     closedir($handler);
     echo json_encode($files);
 }
开发者ID:Toney,项目名称:xmcms,代码行数:27,代码来源:TemplateController.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP pathinfo_filename函数代码示例发布时间:2022-05-15
下一篇:
PHP path_to_theme函数代码示例发布时间: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