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


PHP BaseFileHelper::normalizePath方法代码示例

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


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

示例1: existeDirectorio

 /**
  * Verifica si existe un directorio, si no existe lo crea
  * @param $directorio
  * @throws \yii\base\Exception
  */
 public static function existeDirectorio($directorio)
 {
     $base = BaseFileHelper::normalizePath(Yii::getAlias('@libreria') . '/imagenes/' . $directorio);
     if (!file_exists($base)) {
         BaseFileHelper::createDirectory($base, 0750, true);
     }
 }
开发者ID:alejandrososa,项目名称:AB,代码行数:12,代码来源:ImagenHelper.php

示例2: afterSave

 /**
  * После сохранения
  */
 public function afterSave()
 {
     $this->path = null;
     //Сохраняем файл
     foreach ($this->fields as $field) {
         $isWeb = $this->_webFile[$field];
         $file = null;
         if ($isWeb || ($file = UploadedFile::getInstance($this->owner, $field))) {
             //Директория для сохранения
             $path = $this->getPath($field);
             $files = BaseFileHelper::findFiles($path);
             foreach ($files as $cFile) {
                 @unlink($cFile);
             }
             $fileName = self::normalize($isWeb ? $this->_names[$field] : $file->name);
             $filePath = BaseFileHelper::normalizePath($path . '/' . $fileName);
             // d($filePath);
             if ($this->_webFile[$field]) {
                 $result = @copy($this->_webFile[$field], $filePath);
                 if (!$result) {
                     $fileName = '';
                 }
             } else {
                 $file->saveAs($path . '/' . $fileName);
                 chmod($filePath, 0666);
             }
             $this->owner->updateAttributes(array($field => $fileName));
         }
     }
     $this->setAttach();
 }
开发者ID:h11Nox,项目名称:slug,代码行数:34,代码来源:FileBehavior.php

示例3: getFullUploadPathForFile

 /**
  * generate the abosolute path for a uploaded media file where to store the file.
  * The folder structure is not the same as the virtual structure that is shown in the media browser. Instead for a new uploaded file a folder following the pattern '.../YYYY/MM/DD' will be created.
  * Uses the value of  @see Frontend->getMediarepositoryBasePath() 
  * 
  * @param UploadedFile $file
  * @return string the full path to the storage folder for this file (note: the folder itself will NOT only be created automatically if the optional parameter createFolder is set to true!)
  */
 private function getFullUploadPathForFile($file)
 {
     $currentDate = new \DateTime();
     $cleanedFileName = str_replace(' ', '_', $file->name);
     $formatedPath = $currentDate->format('Y/m/d');
     $targetFolder = BaseFileHelper::normalizePath($this->module->getMediarepositoryBasePath() . DIRECTORY_SEPARATOR . $formatedPath) . DIRECTORY_SEPARATOR;
     $fullFilePath = $targetFolder . $cleanedFileName;
     //check if folder exists, create if not
     if (!file_exists($targetFolder)) {
         if (!mkdir($targetFolder, 0755, true)) {
             throw new \Exception('Could not create target folder: ' . $targetFolder);
         }
     }
     $conflictCounter = 1;
     while (file_exists($fullFilePath)) {
         $fullFilePath = $targetFolder . str_replace(' ', '_', $file->baseName) . '_' . $conflictCounter . '.' . $file->extension;
         $conflictCounter++;
     }
     return $fullFilePath;
 }
开发者ID:keyeMyria,项目名称:yii2-simple-cms,代码行数:28,代码来源:MediaController.php


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