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


PHP FileManager::getUniquePath方法代码示例

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


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

示例1: writeDataToFile

 /**
  * Write data from request into a file
  *
  * @param \PEAR2\HTTP\Request\Response $response Response to get data
  *
  * @return string
  */
 protected function writeDataToFile(\PEAR2\HTTP\Request\Response $response)
 {
     if (!\Includes\Utils\FileManager::isDir(LC_DIR_TMP)) {
         \Includes\Utils\FileManager::mkdir(LC_DIR_TMP);
     }
     if (!\Includes\Utils\FileManager::isDirWriteable(LC_DIR_TMP)) {
         \Includes\ErrorHandler::fireError('Directory "' . LC_DIR_TMP . '" is not writeable');
     }
     $path = \Includes\Utils\FileManager::getUniquePath(LC_DIR_TMP, uniqid() . '.' . \Includes\Utils\PHARManager::getExtension() ?: 'tar');
     return isset($response->body) && \Includes\Utils\FileManager::write($path, $response->body) ? $path : null;
 }
开发者ID:kingsj,项目名称:core,代码行数:18,代码来源:Marketplace.php

示例2: doActionSelectLocalLanguageFile

 /**
  * "Local file" handler for category images.
  * Returns path of the temporary file
  *
  * @return void
  */
 protected function doActionSelectLocalLanguageFile()
 {
     $result = null;
     $path = \XLite\View\BrowseServer::getNormalizedPath(\XLite\Core\Request::getInstance()->local_server_file);
     $tmpPath = \Includes\Utils\FileManager::getUniquePath(LC_DIR_TMP, basename($path));
     if (copy($path, $tmpPath)) {
         $result = $tmpPath;
     }
     $this->doActionSelectLanguageFile($result);
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:16,代码来源:SelectFileAbstract.php

示例3: doActionImport

 /**
  * Import action
  *
  * @return void
  */
 protected function doActionImport()
 {
     foreach (\XLite\Logic\Import\Importer::getImportOptionsList() as $key) {
         \XLite\Core\Database::getRepo('XLite\\Model\\Config')->createOption(array('category' => 'Import', 'name' => $key, 'value' => isset(\XLite\Core\Request::getInstance()->options[$key]) ? \XLite\Core\Request::getInstance()->options[$key] : false));
     }
     \XLite\Core\Config::updateInstance();
     $dirTo = LC_DIR_VAR . \XLite\Logic\Import\Importer::getImportDir();
     if (!\Includes\Utils\FileManager::isExists($dirTo)) {
         \Includes\Utils\FileManager::mkdirRecursive($dirTo);
     }
     $filesToImport = array();
     if ($_FILES && isset($_FILES['files']) && $_FILES['files']['name'] && $_FILES['files']['name'][0] && \Includes\Utils\FileManager::isDirWriteable($dirTo)) {
         $list = glob($dirTo . LC_DS . '*');
         if ($list) {
             foreach ($list as $path) {
                 if (is_file($path)) {
                     \Includes\Utils\FileManager::deleteFile($path);
                 }
             }
         }
         $files = $_FILES['files'];
         foreach ($files['name'] as $key => $name) {
             $path = null;
             if ($name && UPLOAD_ERR_OK === $files['error'][$key]) {
                 $path = \Includes\Utils\FileManager::getUniquePath($dirTo, $name ?: $files['name'][$key]);
                 if (move_uploaded_file($files['tmp_name'][$key], $path)) {
                     if (\XLite\Core\Archive::getInstance()->isArchive($path) || 'csv' == substr(strrchr($path, '.'), 1)) {
                         $filesToImport[] = $path;
                     } else {
                         \XLite\Core\TopMessage::addError('The "{{file}}" is not CSV or archive', array('file' => $name));
                         \Includes\Utils\FileManager::deleteFile($path);
                     }
                 } else {
                     $path = null;
                 }
             }
             if (!$path) {
                 \XLite\Core\TopMessage::addError('The "{{file}}" file was not uploaded', array('file' => $name));
             }
         }
     }
     if ($filesToImport) {
         \XLite\Logic\Import\Importer::run(\XLite\Logic\Import\Importer::assembleImportOptions() + array('files' => $filesToImport));
     }
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:50,代码来源:ImportAbstract.php

示例4: loadFromLocalFile

 /**
  * Load from local file
  *
  * @param string $path     Absolute path
  * @param string $basename File name OPTIONAL
  *
  * @return boolean
  */
 public function loadFromLocalFile($path, $basename = null)
 {
     $result = true;
     $basename = $basename ?: basename($path);
     if (\Includes\Utils\FileManager::isExists($path)) {
         foreach ($this->getAllowedFileSystemRoots() as $root) {
             if (\Includes\Utils\FileManager::getRelativePath($path, $root)) {
                 $local = true;
                 break;
             }
         }
         if (empty($local)) {
             $newPath = \Includes\Utils\FileManager::getUniquePath($this->getStoreFileSystemRoot(), $basename);
             if (\Includes\Utils\FileManager::copy($path, $newPath)) {
                 $path = $newPath;
                 $this->setStorageType(static::STORAGE_RELATIVE);
             } else {
                 \XLite\Logger::getInstance()->log('\'' . $path . '\' file could not be copied to a new location \'' . $newPath . '\'.', LOG_ERR);
                 $result = false;
             }
         } else {
             $this->setStorageType(static::STORAGE_ABSOLUTE);
         }
     } else {
         $result = false;
     }
     if ($result && $basename) {
         $this->setFileName($basename);
     }
     return $result && $this->savePath($path);
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:39,代码来源:Storage.php

示例5: updatePathByMIME

 /**
  * Update file path - change file extension taken from MIME information.
  *
  * @return boolean
  */
 protected function updatePathByMIME()
 {
     $result = parent::updatePathByMIME();
     if ($result && !$this->isURL()) {
         list($path, ) = $this->getLocalPath();
         $newExtension = $this->getExtensionByMIME();
         $pathinfo = pathinfo($path);
         if ($newExtension !== $pathinfo['extension']) {
             $newPath = \Includes\Utils\FileManager::getUniquePath($pathinfo['dirname'], $pathinfo['filename'] . '.' . $newExtension);
             $result = rename($path, $newPath);
             if ($result) {
                 $this->path = basename($newPath);
             }
         }
     }
     return $result;
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:22,代码来源:Image.php

示例6: loadFromURLImport

 /**
  * Load import file from URL 
  * 
  * @param string $url URL
  *  
  * @return string
  */
 protected function loadFromURLImport($url)
 {
     $result = null;
     $content = \XLite\Core\Operator::getURLContent($url);
     $path = \Includes\Utils\FileManager::getUniquePath(LC_DIR_TMP, basename($path));
     if ($content && file_put_contents($path, $content)) {
         $result = $path;
     }
     return $result;
 }
开发者ID:kingsj,项目名称:core,代码行数:17,代码来源:SelectFile.php


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