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


PHP UploadedFile::addFilter方法代码示例

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


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

示例1: validate

 function validate($newItem)
 {
     $extraFields = $this->extraField->getCategoryFieldsWithOptions($newItem->categoryId);
     foreach ($extraFields as $field) {
         $fieldId = $field['fieldId'];
         if ($field['required'] && (empty($newItem->extraField) || empty($newItem->extraField[$fieldId]))) {
             return "You don't fill required field " . $field['name'];
         }
         if ($field['type'] == 'file') {
             $file = new UploadedFile('extraField_' . $fieldId . '_file');
             $extensions = preg_split('/\\s*,\\s*/', $field['config']['extensions']);
             $file->addFilter('extension', $extensions);
             $file->addFilter('maxSize', intval($field['config']['maxSize']) * 1024);
             if ($file->wasUploaded()) {
                 try {
                     $file->validate();
                 } catch (Exception $e) {
                     return $e->getMessage();
                 }
             }
         }
     }
 }
开发者ID:reinfire,项目名称:arfooo,代码行数:23,代码来源:ExtraFieldModel.php

示例2: uploadSiteImageAction

 function uploadSiteImageAction($siteId)
 {
     $this->viewClass = 'JsonView';
     $siteId = intval($siteId);
     $site = $this->site->findByPk($siteId);
     $siteImage = new UploadedFile("siteImage");
     $siteImage->addFilter("extension", array("jpg", "png", "gif"));
     $thumbsPath = Config::get("SITES_THUMBS_PATH");
     $siteImage->setSavePath($thumbsPath);
     $siteImage->save();
     $newImageSrc = $siteImage->getSavedFileName();
     if ($newImageSrc) {
         if ($site->imageSrc) {
             $oldFilePath = $thumbsPath . basename($site->imageSrc);
             if (file_exists($oldFilePath)) {
                 unlink($oldFilePath);
             }
         }
         $site->imageSrc = $newImageSrc;
         $site->save();
     }
     $site->updateImageSrc(false);
     $this->set('status', 'ok');
     $this->set('imageSrc', $site->imageSrc);
 }
开发者ID:reinfire,项目名称:arfooo,代码行数:25,代码来源:SiteController.php

示例3: uploadSiteImageAction

 function uploadSiteImageAction($siteId)
 {
     $siteId = intval($siteId);
     $site = $this->site->findByPk($siteId);
     $siteImage = new UploadedFile("siteImage");
     $siteImage->addFilter("extension", array("jpg", "png", "gif"));
     $thumbsPath = Config::get("SITES_THUMBS_PATH");
     $newImageSrc = $siteImage->save($thumbsPath);
     if ($newImageSrc) {
         if ($site->imageSrc) {
             $oldFilePath = $thumbsPath . basename($site->imageSrc);
             if (file_exists($oldFilePath)) {
                 unlink($oldFilePath);
             }
         }
         $site->imageSrc = $newImageSrc;
         $site->save();
     }
     $site->updateImageSrc(false);
     echo "<html><body>" . $site->imageSrc . "</body></html>";
     $this->autoRender = false;
 }
开发者ID:reinfire,项目名称:arfooo,代码行数:22,代码来源:SiteController.php

示例4: savePackageAction

 function savePackageAction($packageId = null)
 {
     $fields = array('name', 'amount', 'allopassId', 'allopassNumber', 'priority', 'description', 'siteDescriptionMaxLength', 'maxKeywordsCountPerSite', 'backLinkMandatory', 'siteDescriptionHtmlEnabled', 'siteDescriptionHtmlAllowedTags', 'siteDescriptionHtmlAllowedCssProperties', 'siteDescriptionMinLength');
     $data = $this->request->getArray($fields);
     $package = empty($packageId) ? new PackageRecord() : $this->package->findByPk($packageId);
     $package->fromArray($data);
     $siteImage = new UploadedFile("uploadImage");
     $siteImage->addFilter("extension", array("jpg", "png", "gif"));
     if ($siteImage->wasUploaded()) {
         $thumbsPath = Config::get("PACKAGES_THUMBS_PATH");
         $siteImage->setSavePath($thumbsPath);
         $siteImage->save();
         $newImageSrc = $siteImage->getSavedFileName();
         if ($newImageSrc) {
             if (!empty($package->imageSrc)) {
                 $oldFilePath = $thumbsPath . basename($package->imageSrc);
                 if (file_exists($oldFilePath)) {
                     unlink($oldFilePath);
                 }
             }
             $package->imageSrc = $newImageSrc;
         }
     }
     $package->save();
     $this->redirect($this->moduleLink("package"));
 }
开发者ID:reinfire,项目名称:arfooo,代码行数:26,代码来源:SettingController.php

示例5: saveCategoryAction

 function saveCategoryAction()
 {
     $rebuild = false;
     $edit = !empty($this->request->categoryId);
     $imageSrc = false;
     try {
         $file = new UploadedFile("categoryImage");
         $file->addFilter("extension", array("jpg", "gif", "png"));
         //check and save image
         if ($file->wasUploaded()) {
             $file->setSavePath(CODE_ROOT_DIR . 'uploads/images_categories/');
             $file->save();
             $imageSrc = $file->getSavedFileName();
         }
     } catch (Exception $e) {
     }
     if (!$edit && $imageSrc == false) {
         $imageSrc = 'defaultCategoryImage.gif';
     }
     //create and save new category
     $fields = $this->request->getArray(array("name", "urlName", "navigationName", "title", "headerDescription", "possibleTender", "description", "metaDescription", "parentCategoryId", "forbidden"));
     if ($edit) {
         $category = $this->category->findByPk($this->request->categoryId);
         //handle categoryParentId change
         if ($category->parentCategoryId != $this->request->parentCategoryId && $category->changeParent($this->request->parentCategoryId)) {
             $rebuild = true;
         }
     } else {
         $category = new CategoryRecord();
     }
     $category->fromArray($fields);
     if ($imageSrc) {
         if ($edit) {
             $category->removeImage();
         }
         $category->imageSrc = $imageSrc;
     }
     if (empty($category->urlName)) {
         $category->urlName = $category->name;
     }
     $excludeCategoryId = $edit ? $category->categoryId : false;
     $category->urlName = $this->category->getFreeUrlName($category->urlName, $excludeCategoryId);
     $category->save();
     if (!$edit) {
         $this->categoryParent->addNode($this->request->parentCategoryId, $category->categoryId);
     }
     if ($rebuild) {
         $this->categoryParent->moveNode($category->categoryId, $category->parentCategoryId);
         $this->category->updateValidatedSitesCount();
     }
     $redirect = AppRouter::getRewrittedUrl("/admin/category/index/" . $category->parentCategoryId);
     $this->redirect($redirect);
 }
开发者ID:reinfire,项目名称:arfooo,代码行数:53,代码来源:CategoryController.php


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