本文整理汇总了PHP中pathInfo函数的典型用法代码示例。如果您正苦于以下问题:PHP pathInfo函数的具体用法?PHP pathInfo怎么用?PHP pathInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pathInfo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: get_upfile_url
/**
* 获取附件文件URL
* @param string $url
* @param string $suffix
* @param string $path
*/
function get_upfile_url($url, $suffix = '', $path = '')
{
if (empty($url)) {
return;
}
if (!empty($suffix)) {
$info = pathInfo($url);
$url = $info['dirname'] . '/' . $info['filename'] . '_' . $suffix . '.' . $info['extension'];
}
$tmpl = C('TMPL_PARSE_STRING');
if (is_int($path)) {
$path = $tmpl['__ALBUM' . $path . '__'];
} elseif (empty($path)) {
$search = array('__COMMON__', '__SD__', '__HD__', '__THEME__');
$replace = array($tmpl['__COMMON__'], $tmpl['__SD__'], $tmpl['__HD__'], $tmpl['__THEME__']);
foreach (C('ALBUM_TYPE') as $key => $v) {
$search[] = 'album' . $key;
$replace[] = 'album' . $tmpl[$key];
}
$url = str_replace($search, $replace, $url);
if (substr($url, 0, 1) == '/' || substr($url, 0, 2) == './' || substr($url, 0, 3) == '../' || substr($url, 0, 7) == 'http://' || substr($url, 0, 8) == 'https://' || substr($url, 0, 6) == 'ftp://') {
return $url;
} else {
$path = $tmpl['__UPFILE__'];
}
}
if (substr($path, -1) != '/') {
$path .= '/';
}
return $path . $url;
}
开发者ID:dalinhuang,项目名称:edu_hipi,代码行数:37,代码来源:common.php
示例2: image_createThumb
function image_createThumb($src, $dest, $maxWidth, $maxHeight, $quality = 75)
{
if (file_exists($src) && isset($dest)) {
// path info
$destInfo = pathInfo($dest);
// image src size
$srcSize = getImageSize($src);
// image dest size $destSize[0] = width, $destSize[1] = height
$srcRatio = $srcSize[0] / $srcSize[1];
// width/height ratio
$destRatio = $maxWidth / $maxHeight;
if ($destRatio > $srcRatio) {
$destSize[1] = $maxHeight;
$destSize[0] = $maxHeight * $srcRatio;
} else {
$destSize[0] = $maxWidth;
$destSize[1] = $maxWidth / $srcRatio;
}
// path rectification
if ($destInfo['extension'] == "gif") {
$dest = substr_replace($dest, 'jpg', -3);
}
// true color image, with anti-aliasing
$destImage = imageCreateTrueColor($destSize[0], $destSize[1]);
// imageAntiAlias($destImage,true);
// src image
switch ($srcSize[2]) {
case 1:
//GIF
$srcImage = imageCreateFromGif($src);
break;
case 2:
//JPEG
$srcImage = imageCreateFromJpeg($src);
break;
case 3:
//PNG
$srcImage = imageCreateFromPng($src);
break;
default:
return false;
break;
}
// resampling
imageCopyResampled($destImage, $srcImage, 0, 0, 0, 0, $destSize[0], $destSize[1], $srcSize[0], $srcSize[1]);
// generating image
switch ($srcSize[2]) {
case 1:
case 2:
imageJpeg($destImage, $dest, $quality);
break;
case 3:
imagePng($destImage, $dest);
break;
}
return true;
} else {
return 'No such File';
}
}
开发者ID:rolfvandervleuten,项目名称:DeepskyLog,代码行数:60,代码来源:resize.php
示例3: getThumbFilename
/**
*
* get filename for thumbnail save / retrieve
* TODO: do input validations - security measures
*/
private function getThumbFilename()
{
$info = pathInfo($this->filename);
//add dirname as postfix (if exists)
$postfix = "";
$dirname = UniteFunctionsRev::getVal($info, "dirname");
if (!empty($dirname)) {
$postfix = str_replace("/", "-", $dirname);
}
$ext = $info["extension"];
$name = $info["filename"];
$width = ceil($this->maxWidth);
$height = ceil($this->maxHeight);
$thumbFilename = $name . "_" . $width . "x" . $height;
if (!empty($this->type)) {
$thumbFilename .= "_" . $this->type;
}
if (!empty($this->effect)) {
$thumbFilename .= "_e" . $this->effect;
if (!empty($this->effect_arg1)) {
$thumbFilename .= "x" . $this->effect_arg1;
}
}
//add postfix
if (!empty($postfix)) {
$thumbFilename .= "_" . $postfix;
}
$thumbFilename .= "." . $ext;
return $thumbFilename;
}
开发者ID:par-orillonsoft,项目名称:elearning-wordpress,代码行数:35,代码来源:image_view.class.php
示例4: validateExtension
/**
* @param $name
* @throws InvalidArgumentException
*/
private function validateExtension($name)
{
$pathInfo = pathInfo($name);
if (!array_key_exists('extension', $pathInfo)) {
throw new InvalidArgumentException("Image extension can't be empty.");
}
if (!in_array($pathInfo['extension'], $this->availableExtensions)) {
throw new InvalidArgumentException("Image needs to have jpeg extension.");
}
}
开发者ID:karion,项目名称:mydrinks,代码行数:14,代码来源:Image.php
示例5: zipDir
/**
* Zip a folder (including itself).
* Usage:
* <code>HZip::zipDir('/path/to/sourceDir', '/path/to/out.zip');</code>
*
* @param string $sourcePath Path of directory to be zip.
* @param string $outZipPath Path of output zip file.
*/
public static function zipDir($sourcePath, $outZipPath)
{
$pathInfo = pathInfo($sourcePath);
$parentPath = $pathInfo['dirname'];
$dirName = $pathInfo['basename'];
$z = new ZipArchive();
$z->open($outZipPath, ZIPARCHIVE::CREATE);
$z->addEmptyDir($dirName);
self::folderToZip($sourcePath, $z, strlen($sourcePath) - strlen($dirName));
$z->close();
}
开发者ID:umbalaconmeogia,项目名称:php-util,代码行数:19,代码来源:Zip.php
示例6: run
/**
* @param string[] $args
* @return void
*/
public function run(array $args)
{
if (0 == count($args)) {
$this->stop('Please pass new configuration name and it\'s parent(s)', 1);
}
if (1 == count($args)) {
$this->stop('Please pass new configuration parent(s) or string NONE if no parents', 1);
}
$name = $args[0];
$parents = $args;
$base = $this->getApplication()->rootDir . DIRECTORY_SEPARATOR . 'settings';
$new = $base . DIRECTORY_SEPARATOR . $name;
array_shift($parents);
if (file_exists($new)) {
echo 'Using setup directory', PHP_EOL, "\t", $new, PHP_EOL;
} else {
echo 'Creating new setup directory', PHP_EOL, "\t", $new, PHP_EOL;
mkDir($new, 0755, true);
}
if (in_array('NONE', $parents)) {
echo "\t\t", 'no parents', PHP_EOL;
$parents = array();
} else {
file_put_contents($new . DIRECTORY_SEPARATOR . \Nano\Application\Config\Builder::PARENTS_FILE, '<?php return ' . var_export($parents, true) . ';');
echo "\t\t", \Nano\Application\Config\Builder::PARENTS_FILE, PHP_EOL;
}
foreach ($parents as $parent) {
$i = new \DirectoryIterator($base . DIRECTORY_SEPARATOR . $parent);
foreach ($i as $file) {
if ($file->isDir() || $file->isDir() || !$file->isReadable()) {
continue;
}
if (\Nano\Application\Config\Builder::PARENTS_FILE === $file->getBaseName()) {
continue;
}
if (\Nano\Application\Config\Builder::ROUTES_FILE === $file->getBaseName()) {
continue;
}
if ('php' !== pathInfo($file->getBaseName(), PATHINFO_EXTENSION)) {
continue;
}
$newFile = $new . DIRECTORY_SEPARATOR . $file->getBaseName();
if (file_exists($newFile)) {
continue;
}
file_put_contents($newFile, '<?php return array(' . PHP_EOL . ');');
echo "\t\t", $file->getBaseName(), PHP_EOL;
}
}
echo "\t\t", \Nano\Application\Config\Builder::ROUTES_FILE, PHP_EOL;
file_put_contents($new . DIRECTORY_SEPARATOR . \Nano\Application\Config\Builder::ROUTES_FILE, '<?php' . PHP_EOL . PHP_EOL);
echo 'Done', PHP_EOL;
}
开发者ID:visor,项目名称:nano,代码行数:57,代码来源:config.php
示例7: iterate
/**
* @param $path
* @param $subjects
* @param $namespace
*/
private function iterate($path, $subjects, $namespace)
{
foreach ($subjects as $subject) {
$pathInfo = pathInfo($subject);
if (is_dir($subject)) {
$this->searchDir($path . '/' . $pathInfo['basename'], $namespace . '\\' . $pathInfo['basename']);
} else {
if ($pathInfo['extension'] === 'php' && $pathInfo['filename'] !== 'BaseRoute') {
$this->routes[] = $namespace . '\\' . $pathInfo['filename'];
}
}
}
}
开发者ID:Archcry,项目名称:PhalconApiBase,代码行数:18,代码来源:RouteLoader.php
示例8: zip
public static function zip($sourcePath, $outZipPath, $isDirectory = true)
{
$pathInfo = pathInfo($sourcePath);
$parentPath = $pathInfo['dirname'];
$dirName = $pathInfo['basename'];
$z = new ZipArchive();
$z->open($outZipPath, ZIPARCHIVE::CREATE);
if ($isDirectory) {
$z->addEmptyDir($dirName);
self::folderToZip($sourcePath, $z, strlen("{$parentPath}/"));
} else {
$z->addFile($sourcePath, $dirName);
}
return $z->close();
}
开发者ID:heartshare,项目名称:Yii2-Helpers-4,代码行数:15,代码来源:Common.php
示例9: compressFolder
/**
* @access public
* @author "Lionel Lecaque, <[email protected]>"
* @param string $src
* @param string $dest
* @param string $includeDir
*/
public static function compressFolder($src, $dest, $includeDir = false)
{
$pathInfo = pathInfo($src);
$parentPath = $pathInfo['dirname'];
$dirName = $pathInfo['basename'];
$z = new ZipArchive();
$z->open($dest, ZipArchive::OVERWRITE);
$exclusiveLength = strlen("{$src}/");
if ($includeDir) {
$z->addEmptyDir($dirName);
$exclusiveLength = strlen("{$parentPath}/");
}
self::folderToZip($src, $z, $exclusiveLength);
$z->close();
}
开发者ID:llecaque,项目名称:extension-tao-update,代码行数:22,代码来源:class.Zip.php
示例10: ckeup
public function ckeup()
{
$targetFolder = '/public/uploads';
$targetPath = $_SERVER['DOCUMENT_ROOT'] . $targetFolder;
$targetFile = $targetPath . '/' . $_FILES['upload']['name'];
$fileTypes = array('jpg', 'jpeg', 'gif', 'png');
$uploadFilename = $_FILES['upload']['name'];
$extensions = pathInfo($uploadFilename, PATHINFO_EXTENSION);
if (in_array($extensions, $fileTypes)) {
move_uploaded_file($_FILES['upload']['tmp_name'], $targetFile);
$previewname = $targetFile;
$callback = $_REQUEST["CKEditorFuncNum"];
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction({$callback},'" . $previewname . "','');</script>";
// Array ( [upload] => Array ( [name] => 123.png [type] => image/png [tmp_name] => F:\uploads\php41FF.tmp [error] => 0 [size] => 11857 ) )
}
}
开发者ID:156248605,项目名称:cishop,代码行数:16,代码来源:test.php
示例11: upload
/**
* 富文本的图片上传功能,基于ckedit
* 配置路径在/public/packages/frozennode/administrator/js/ckedit/config.js
*/
public function upload()
{
$extensions = array('jpg', 'bmp', 'gif', 'png');
$uploadFilename = $_FILES['upload']['name'];
$extension = pathInfo($uploadFilename, PATHINFO_EXTENSION);
if (in_array($extension, $extensions)) {
$uploadPath = public_path() . '/uploads/products/article/';
$uuid = str_replace('.', '', uniqid("", TRUE)) . "." . $extension;
$desname = $uploadPath . $uuid;
$previewname = '/uploads/products/article/' . $uuid;
$tag = move_uploaded_file($_FILES['upload']['tmp_name'], $desname);
$callback = $_REQUEST["CKEditorFuncNum"];
echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction({$callback},'" . $previewname . "','');</script>";
} else {
echo "<font color=\"red\"size=\"2\">*文件格式不正确(必须为.jpg/.gif/.bmp/.png文件)</font>";
}
}
开发者ID:JackyZhan,项目名称:laraveladmin,代码行数:21,代码来源:ArticleController.php
示例12: init
public function init()
{
$Directory = new RecursiveDirectoryIterator(APPPATH . 'modules');
$Iterator = new RecursiveIteratorIterator($Directory);
$Models = new RegexIterator($Iterator, '/^.+\\_dashboard_model.php$/i', RecursiveRegexIterator::GET_MATCH);
foreach ($Models as $k => $v) {
$this->_modules[] = $k;
}
$this->_exceptions[] = '';
// nothing at the moment...
$this->_modules = array_diff($this->_modules, $this->_exceptions);
foreach ($this->_modules as $k => $v) {
$classname = pathInfo($v, PATHINFO_FILENAME);
if (is_file($v)) {
$this->CI->load->file($v);
}
$this->CI->load->file(FCPATH . APPPATH . '/modules/users/helpers/dashboard_helper.php');
$class = new $classname();
}
}
开发者ID:RCDawson,项目名称:bhp,代码行数:20,代码来源:Dashboard.php
示例13: run
/**
* @return void
* @param string[] $args
*/
public function run(array $args)
{
$iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->getApplication()->rootDir), \RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $file) {
/** @var \DirectoryIterator $file */
if ($file->isDir()) {
continue;
}
if ('php' != pathInfo($file->getBaseName(), PATHINFO_EXTENSION)) {
continue;
}
$source = file_get_contents($file->getPathName());
$result = $this->convertLineEnds($source);
$result = $this->removeTrailingSpaces($result);
$result = $this->convertIndentationSpaces($result);
if ($source === $result) {
continue;
}
file_put_contents($file->getPathName(), $result);
echo $file->getPathName(), PHP_EOL;
}
}
开发者ID:visor,项目名称:nano,代码行数:26,代码来源:fix-spaces.php
示例14: __construct
/**
* Constructor
*
* @param PHPRtfLite $rtf
* @param string $imageFile image file incl. path
* @param float $width
* @param flaot $height
*/
public function __construct(PHPRtfLite $rtf, $imageFile, PHPRtfLite_ParFormat $parFormat = null, $width = null, $height = null)
{
$this->_rtf = $rtf;
$this->_parFormat = $parFormat;
if (file_exists($imageFile)) {
$this->_file = $imageFile;
$pathInfo = pathInfo($imageFile);
if (isset($pathInfo['extension'])) {
$this->_extension = strtolower($pathInfo['extension']);
}
list($this->_defaultWidth, $this->_defaultHeight) = getimagesize($imageFile);
if ($width !== null) {
$this->setWidth($width);
}
if ($height !== null) {
$this->setHeight($height);
}
} else {
$this->_defaultWidth = 20;
$this->_defaultHeight = 20;
$this->_extension = 'png';
}
}
开发者ID:TRWirahmana,项目名称:sekretariat,代码行数:31,代码来源:Image.php
示例15: set
/**
* {@inheritDoc}
*/
public function set($key, $value)
{
$pathInfo = pathInfo($this->cachedFile());
$cacheDir = $pathInfo['dirname'];
$fileName = $pathInfo['basename'];
ErrorHandler::start();
if (!is_dir($cacheDir)) {
$umask = umask(0);
mkdir($cacheDir, 0777, true);
umask($umask);
// @codeCoverageIgnoreStart
}
// @codeCoverageIgnoreEnd
ErrorHandler::stop();
if (!is_writable($cacheDir)) {
throw new RuntimeException('Unable to write file ' . $this->cachedFile());
}
// Use "rename" to achieve atomic writes
$tmpFilePath = $cacheDir . '/AssetManagerFilePathCache_' . $fileName;
if (@file_put_contents($tmpFilePath, $value, LOCK_EX) === false) {
throw new RuntimeException('Unable to write file ' . $this->cachedFile());
}
rename($tmpFilePath, $this->cachedFile());
}
开发者ID:crsoares,项目名称:assetmanager,代码行数:27,代码来源:FilePathCache.php
示例16: saveImage
public function saveImage($savePath, $imageQuality = "100")
{
// *** Perform a check or two.
if (!is_resource($this->imageResized)) {
if ($this->debug) {
throw new Exception('saveImage: This is not a resource.');
} else {
throw new Exception();
}
}
$fileInfoArray = pathInfo($savePath);
clearstatcache();
if (!is_writable($fileInfoArray['dirname'])) {
if ($this->debug) {
throw new Exception('The path is not writable. Please check your permissions.');
} else {
throw new Exception();
}
}
// *** Get extension
$extension = strrchr($savePath, '.');
$extension = fix_strtolower($extension);
$error = '';
switch ($extension) {
case '.jpg':
case '.jpeg':
$this->checkInterlaceImage($this->isInterlace);
if (imagetypes() & IMG_JPG) {
imagejpeg($this->imageResized, $savePath, $imageQuality);
} else {
$error = 'jpg';
}
break;
case '.gif':
$this->checkInterlaceImage($this->isInterlace);
if (imagetypes() & IMG_GIF) {
imagegif($this->imageResized, $savePath);
} else {
$error = 'gif';
}
break;
case '.png':
// *** Scale quality from 0-100 to 0-9
$scaleQuality = round($imageQuality / 100 * 9);
// *** Invert qualit setting as 0 is best, not 9
$invertScaleQuality = 9 - $scaleQuality;
$this->checkInterlaceImage($this->isInterlace);
if (imagetypes() & IMG_PNG) {
imagepng($this->imageResized, $savePath, $invertScaleQuality);
} else {
$error = 'png';
}
break;
case '.bmp':
file_put_contents($savePath, $this->GD2BMPstring($this->imageResized));
break;
// ... etc
// ... etc
default:
// *** No extension - No save.
$this->errorArray[] = 'This file type (' . $extension . ') is not supported. File not saved.';
break;
}
//imagedestroy($this->imageResized);
// *** Display error if a file type is not supported.
if ($error != '') {
$this->errorArray[] = $error . ' support is NOT enabled. File not saved.';
}
}
开发者ID:WebPassions,项目名称:2015,代码行数:69,代码来源:php_image_magician.php
示例17: getMediaIfAlreadyExists
/**
* Get media file if it exists
*
* @param \GeorgRinger\News\Domain\Model\News $news
* @param string $mediaFile
* @return Boolean|\GeorgRinger\News\Domain\Model\Media
*/
protected function getMediaIfAlreadyExists(\GeorgRinger\News\Domain\Model\News $news, $mediaFile)
{
$result = FALSE;
$mediaItems = $news->getMedia();
if (isset($mediaItems) && $mediaItems->count() !== 0) {
foreach ($mediaItems as $mediaItem) {
$pathInfoItem = pathinfo($mediaItem->getImage());
$pathInfoMediaFile = pathInfo($mediaFile);
if (GeneralUtility::isFirstPartOfStr($pathInfoItem['filename'], $pathInfoMediaFile['filename']) && $this->filesAreEqual(PATH_site . $mediaFile, PATH_site . self::UPLOAD_PATH . $mediaItem->getImage())) {
$result = $mediaItem;
break;
}
}
}
return $result;
}
开发者ID:r3h6,项目名称:news,代码行数:23,代码来源:NewsImportService.php
示例18: loadClassesWithEvents
private function loadClassesWithEvents()
{
$dir = ROOT . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR;
foreach ((array) cf('classes with events') as $filename) {
$filename = $dir . $filename . ".php";
$filePath = pathInfo($filename);
//php4 incompatibility
$className = $filePath['filename'];
if ($filePath['filename'] != 'core' && ($filePath['extension'] = 'php')) {
if (!(include_once $filename)) {
echo "Class w/event load failed: {$className} : file {$filename} not found.";
return false;
}
if (!class_exists($className)) {
echo "Class w/event load failed: {$className}.php doesn't actually have said class declared.";
return false;
} else {
$this->events->registerClassEventListeners($className);
}
}
}
}
开发者ID:slact,项目名称:webylene-php,代码行数:22,代码来源:core.php
示例19: getFileExtension
/**
* Returns the file extension used for this resource
*
* @return string The file extension used for this file
* @api
*/
public function getFileExtension()
{
$pathInfo = pathInfo($this->filename);
return isset($pathInfo['extension']) ? $pathInfo['extension'] : '';
}
开发者ID:kszyma,项目名称:flow-development-collection,代码行数:11,代码来源:Resource.php
示例20: mime_type_identify
function mime_type_identify($file)
{
$ext = strtolower(pathInfo($file, PATHINFO_EXTENSION));
return isset($GLOBALS['_mime_type_extensions'][$ext]) ? $GLOBALS['_mime_type_extensions'][$ext] : 'binary/octet-stream';
}
开发者ID:nilswalk,项目名称:parallel-flickr,代码行数:5,代码来源:lib_mime_type.php
注:本文中的pathInfo函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论