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


PHP PublicFileManager::uploadError方法代码示例

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


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

示例1: uploadProfileImage

 function uploadProfileImage()
 {
     import('file.PublicFileManager');
     $fileManager = new PublicFileManager();
     $user =& $this->user;
     $type = $fileManager->getUploadedFileType('profileImage');
     $extension = $fileManager->getImageExtension($type);
     if (!$extension) {
         return false;
     }
     $uploadName = 'profileImage-' . (int) $user->getId() . $extension;
     if ($fileManager->uploadError('profileImage')) {
         return false;
     }
     if (!$fileManager->uploadSiteFile('profileImage', $uploadName)) {
         return false;
     }
     $filePath = $fileManager->getSiteFilesPath();
     list($width, $height) = getimagesize($filePath . '/' . $uploadName);
     if ($width > 150 || $height > 150 || $width <= 0 || $height <= 0) {
         $userSetting = null;
         $user->updateSetting('profileImage', $userSetting);
         $fileManager->removeSiteFile($filePath);
         return false;
     }
     $userSetting = array('name' => $fileManager->getUploadedFileName('profileImage'), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'dateUploaded' => Core::getCurrentDate());
     $user->updateSetting('profileImage', $userSetting);
     return true;
 }
开发者ID:jmacgreg,项目名称:ocs,代码行数:29,代码来源:ProfileForm.inc.php

示例2: uploadStyleSheet

 /**
  * Uploads conference custom stylesheet.
  * @param $settingName string setting key associated with the file
  */
 function uploadStyleSheet($settingName)
 {
     $conference =& Request::getConference();
     $settingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO');
     import('file.PublicFileManager');
     $fileManager = new PublicFileManager();
     if ($fileManager->uploadError($settingName)) {
         return false;
     }
     if ($fileManager->uploadedFileExists($settingName)) {
         $type = $fileManager->getUploadedFileType($settingName);
         if ($type != 'text/plain' && $type != 'text/css') {
             return false;
         }
         $uploadName = $settingName . '.css';
         if ($fileManager->uploadConferenceFile($conference->getId(), $settingName, $uploadName)) {
             $value = array('name' => $fileManager->getUploadedFileName($settingName), 'uploadName' => $uploadName, 'dateUploaded' => date("Y-m-d g:i:s"));
             $settingsDao->updateSetting($conference->getId(), $settingName, $value, 'object');
             return true;
         }
     }
     return false;
 }
开发者ID:sedici,项目名称:ocs,代码行数:27,代码来源:ConferenceSetupStep4Form.inc.php

示例3: uploadImage

 /**
  * Uploads a conference image.
  * @param $settingName string setting key associated with the file
  * @param $locale string
  */
 function uploadImage($settingName, $locale)
 {
     $conference =& Request::getConference();
     $settingsDao = DAORegistry::getDAO('ConferenceSettingsDAO');
     $faviconTypes = array('.ico', '.png', '.gif');
     import('classes.file.PublicFileManager');
     $fileManager = new PublicFileManager();
     if ($fileManager->uploadError($settingName)) {
         return false;
     }
     if ($fileManager->uploadedFileExists($settingName)) {
         $type = $fileManager->getUploadedFileType($settingName);
         $extension = $fileManager->getImageExtension($type);
         if (!$extension) {
             return false;
         }
         if ($settingName == 'conferenceFavicon' && !in_array($extension, $faviconTypes)) {
             return false;
         }
         $uploadName = $settingName . '_' . $locale . $extension;
         if ($fileManager->uploadConferenceFile($conference->getId(), $settingName, $uploadName)) {
             // Get image dimensions
             $filePath = $fileManager->getConferenceFilesPath($conference->getId());
             list($width, $height) = getimagesize($filePath . '/' . $uploadName);
             $value = $conference->getSetting($settingName);
             $value[$locale] = array('name' => $fileManager->getUploadedFileName($settingName), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'mimeType' => $fileManager->getUploadedFileType($settingName), 'dateUploaded' => Core::getCurrentDate());
             $settingsDao->updateSetting($conference->getId(), $settingName, $value, 'object', true);
             return true;
         }
     }
     return false;
 }
开发者ID:artkuo,项目名称:ocs,代码行数:37,代码来源:ConferenceSetupForm.inc.php

示例4: saveLocationSettings

 /**
  * Save changes to location settings.
  */
 function saveLocationSettings()
 {
     $this->validate();
     $this->setupTemplate(true);
     $schedConf =& Request::getSchedConf();
     if (!$schedConf) {
         Request::redirect(null, null, 'index');
     }
     import('manager.form.LocationSettingsForm');
     $settingsForm = new LocationSettingsForm();
     $settingsForm->readInputData();
     $editData = false;
     $locationFiles =& $schedConf->getSetting('locationFiles');
     if (Request::getUserVar('uploadLocationFile')) {
         // Get a numeric key for this file.
         $thisFileKey = 0;
         if (isset($locationFiles[$settingsForm->getFormLocale()])) {
             foreach ($locationFiles[$settingsForm->getFormLocale()] as $key => $junk) {
                 $thisFileKey = $key + 1;
             }
         }
         import('file.PublicFileManager');
         $fileManager = new PublicFileManager();
         $success = !$fileManager->uploadError('locationFile');
         if ($success && ($success = $fileManager->uploadedFileExists('locationFile'))) {
             $oldName = $fileManager->getUploadedFileName('locationFile');
             $extension = $fileManager->getExtension($oldName);
             if (!$extension) {
                 break;
             }
             $uploadName = 'location-' . $thisFileKey . '.' . $extension;
             if ($success && ($success = $fileManager->uploadSchedConfFile($schedConf->getId(), 'locationFile', $uploadName))) {
                 $value = array('name' => $oldName, 'uploadName' => $uploadName, 'dateUploaded' => Core::getCurrentDate(), 'title' => Request::getUserVar('locationFileTitle'));
                 $locationFiles[$settingsForm->getFormLocale()][$thisFileKey] =& $value;
                 $settingsForm->setData('locationFiles', $locationFiles);
                 $settingsForm->setData('locationFileTitle', '');
                 $schedConf->updateSetting('locationFiles', $locationFiles, 'object', true);
             }
         }
         if (!$success) {
             $settingsForm->addError('locationFiles', __('common.uploadFailed'));
         }
         $editData = true;
     } else {
         $formLocale = $settingsForm->getFormLocale();
         $deleteKey = null;
         if (isset($locationFiles[$formLocale])) {
             foreach ($locationFiles[$formLocale] as $key => $junk) {
                 if (Request::getUserVar("deleteLocationFile-{$formLocale}-{$key}")) {
                     $deleteKey = $key;
                 }
             }
         }
         if ($deleteKey !== null) {
             import('file.PublicFileManager');
             $fileManager = new PublicFileManager();
             if ($fileManager->removeSchedConfFile($schedConf->getId(), $locationFiles[$formLocale][$deleteKey]['uploadName'])) {
                 unset($locationFiles[$formLocale][$deleteKey]);
                 $schedConf->updateSetting('locationFiles', $locationFiles, 'object', true);
             }
             $editData = true;
         }
     }
     if (!$editData && $settingsForm->validate()) {
         $settingsForm->execute();
         $templateMgr =& TemplateManager::getManager();
         $templateMgr->assign(array('currentUrl' => Request::url(null, null, null, 'location'), 'pageTitle' => 'schedConf.location', 'message' => 'common.changesSaved', 'backLink' => Request::url(null, null, Request::getRequestedPage()), 'backLinkLabel' => 'manager.conferenceSiteManagement'));
         $templateMgr->display('common/message.tpl');
     } else {
         $settingsForm->display();
     }
 }
开发者ID:pulipulichen,项目名称:ocs,代码行数:75,代码来源:ManagerLocationHandler.inc.php

示例5: uploadProgram

 /**
  * Uploads a program file.
  * @param $settingName string setting key associated with the file
  * @param $locale string
  */
 function uploadProgram($settingName, $locale)
 {
     $schedConf =& Request::getSchedConf();
     import('file.PublicFileManager');
     $fileManager = new PublicFileManager();
     if ($fileManager->uploadError($settingName)) {
         return false;
     }
     if ($fileManager->uploadedFileExists($settingName)) {
         $oldName = $fileManager->getUploadedFileName('programFile');
         $extension = $fileManager->getExtension($oldName);
         if (!$extension) {
             return false;
         }
         $uploadName = 'program-' . $locale . '.' . $extension;
         if ($fileManager->uploadSchedConfFile($schedConf->getId(), $settingName, $uploadName)) {
             $value = $schedConf->getSetting($settingName);
             $value[$locale] = array('name' => $oldName, 'uploadName' => $uploadName, 'dateUploaded' => Core::getCurrentDate());
             $schedConf->updateSetting($settingName, $value, 'object', true);
             return true;
         }
     }
     return false;
 }
开发者ID:jalperin,项目名称:ocs,代码行数:29,代码来源:ProgramSettingsForm.inc.php


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