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


PHP FileManager::moveUploadedFile方法代码示例

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


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

示例1: setModelProperties

 /**
  * Populate model object properties by the passed data
  *
  * @param array $data Data to set
  *
  * @return void
  */
 protected function setModelProperties(array $data)
 {
     $options = $this->getOptions();
     $dir = LC_DIR_SKINS . \XLite\Core\Layout::PATH_COMMON . LC_DS;
     if ('CDev\\SimpleCMS' == $options[0]->category) {
         if ($_FILES && $_FILES['logo'] && $_FILES['logo']['name']) {
             $path = \Includes\Utils\FileManager::moveUploadedFile('logo', $dir);
             if ($path) {
                 if ($options[0]->value) {
                     \Includes\Utils\FileManager::deleteFile($dir . $options[0]->value);
                 }
                 $data['logo'] = basename($path);
             }
         } elseif (\XLite\Core\Request::getInstance()->useDefaultLogo) {
             $data['logo'] = '';
             if ($options[0]->value) {
                 \Includes\Utils\FileManager::deleteFile($dir . $options[0]->value);
             }
         } else {
             $data['logo'] = $options[0]->value;
         }
     }
     parent::setModelProperties($data);
 }
开发者ID:kingsj,项目名称:core,代码行数:31,代码来源:Settings.php

示例2: doActionUploadAddon

 /**
  * Install uploaded add-on
  *
  * @return void
  */
 protected function doActionUploadAddon()
 {
     $this->setReturnURL($this->buildURL('addons_list_installed'));
     $path = \Includes\Utils\FileManager::moveUploadedFile('modulePack');
     if ($path) {
         \XLite\Upgrade\Cell::getInstance()->clear(true, true, false);
         $entry = \XLite\Upgrade\Cell::getInstance()->addUploadedModule($path);
         if (!isset($entry)) {
             $this->showError(__FUNCTION__, static::t('unable to add module entry to the installation list: X', array('path' => $path)));
         } elseif (\XLite::getInstance()->checkVersion($entry->getMajorVersionNew(), '!=')) {
             $this->showError(__FUNCTION__, static::t('module version X is not equal to the core one (Y)', array('module_version' => $entry->getMajorVersionNew(), 'core_version' => \XLite::getInstance()->getMajorVersion())));
         } elseif ($this->isNextStepAvailable()) {
             $this->setReturnURL($this->buildURL('upgrade', 'download', $this->getActionParamsCommon(true)));
         } else {
             $this->showError(__FUNCTION__);
         }
     } else {
         $this->showError(__FUNCTION__, static::t('unable to upload module'));
     }
 }
开发者ID:kirkbauer2,项目名称:kirkxc,代码行数:25,代码来源:Upgrade.php

示例3: prepareImageData

 /**
  * Additional preparations for images.
  * Upload them into specific directory
  *
  * @param string $optionValue Option value
  * @param string $imageType   Image type
  *
  * @return string
  */
 protected function prepareImageData($optionValue, $imageType)
 {
     $dir = static::getLogoFaviconDir();
     if ($_FILES && $_FILES[$imageType] && $_FILES[$imageType]['name']) {
         $path = null;
         $realName = preg_replace('/([^a-zA-Z0-9_\\-\\.]+)/', '_', $_FILES[$imageType]['name']);
         if ($this->isImage($_FILES[$imageType]['tmp_name'], $realName)) {
             if (!\Includes\Utils\FileManager::isDir($dir)) {
                 \Includes\Utils\FileManager::mkdirRecursive($dir);
             }
             if (\Includes\Utils\FileManager::isDir($dir)) {
                 // Remove file with same name as uploaded file in the destination directory
                 \Includes\Utils\FileManager::deleteFile($dir . LC_DS . ('favicon' === $imageType ? static::FAVICON : $realName));
                 // Move uploaded file to destination directory
                 $path = \Includes\Utils\FileManager::moveUploadedFile($imageType, $dir, 'favicon' === $imageType ? static::FAVICON : $realName);
                 if ($path) {
                     if ($optionValue && 'favicon' !== $imageType && basename($optionValue) != $realName) {
                         // Remove old image file
                         \Includes\Utils\FileManager::deleteFile($dir . basename($optionValue));
                     }
                     $optionValue = static::getLogoFaviconSubDir() . basename($path);
                 }
             }
             if (!isset($path)) {
                 $this->logoFaviconValidation = false;
                 \XLite\Core\TopMessage::addError('The "{{file}}" file was not uploaded', array('file' => $realName));
             }
         } else {
             $this->logoFaviconValidation = false;
             \XLite\Core\TopMessage::addError('The "{{file}}" file is not allowed image and was not uploaded. Allowed images are: {{extensions}}', array('file' => $realName, 'extensions' => implode(', ', $this->getImageExtensions())));
         }
     } elseif (\XLite\Core\Request::getInstance()->useDefaultImage[$imageType]) {
         if ($optionValue) {
             \Includes\Utils\FileManager::deleteFile($dir . basename($optionValue));
         }
         $optionValue = '';
     }
     return $optionValue;
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:48,代码来源:Settings.php

示例4: loadFromRequest

 /**
  * Load from request
  *
  * @param string $key Key in $_FILES service array
  *
  * @return boolean
  */
 public function loadFromRequest($key)
 {
     $path = \Includes\Utils\FileManager::moveUploadedFile($key, $this->getStoreFileSystemRoot());
     if ($path) {
         $this->setStorageType(static::STORAGE_RELATIVE);
         if (!empty($_FILES[$key]['type'])) {
             $this->setMime($_FILES[$key]['type']);
         }
         if (!$this->savePath($path)) {
             \Includes\Utils\FileManager::deleteFile($path);
             $path = null;
         }
     } else {
         \XLite\Logger::getInstance()->log('The file was not loaded', LOG_ERR);
     }
     return !empty($path);
 }
开发者ID:kewaunited,项目名称:xcart,代码行数:24,代码来源:Storage.php

示例5: loadFromRequest

 /**
  * Load from request
  *
  * @param string $key Key in $_FILES service array
  *
  * @return boolean
  */
 public function loadFromRequest($key)
 {
     if (!$this->s3Forbid && $this->getS3()) {
         $result = false;
         $path = \Includes\Utils\FileManager::moveUploadedFile($key, LC_DIR_TMP);
         if ($path) {
             $result = $this->loadFromLocalFile($path, $_FILES[$key]['name']);
             \Includes\Utils\FileManager::deleteFile($path);
         } else {
             \XLite\Logger::getInstance()->log('The file was not loaded', LOG_ERR);
         }
     } else {
         $result = parent::loadFromRequest($key);
     }
     return $result;
 }
开发者ID:kingsj,项目名称:core,代码行数:23,代码来源:Image.php


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