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