當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。