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


PHP pathinfo函数代码示例

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


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


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