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


PHP Kurogo::file_upload_error_message方法代码示例

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


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

示例1: uploadFile

 private function uploadFile($type, $section, $subsection, $key, $value)
 {
     $sectionData = $this->getAdminData($type, $section, $subsection);
     if (isset($value['error']) && $value['error'] != UPLOAD_ERR_OK) {
         throw new KurogoDataException(Kurogo::file_upload_error_message($value['error']));
     }
     if (!isset($value['tmp_name']) || !is_uploaded_file($value['tmp_name'])) {
         throw new KurogoDataException("Error locating uploaded file");
     }
     switch ($sectionData['sectiontype']) {
         case 'fields':
             if (!isset($sectionData['fields'][$key])) {
                 throw new KurogoConfigurationException("Invalid key {$key} for {$type} section {$section}");
             }
             $fieldData = $sectionData['fields'][$key];
             break;
         case 'section':
             $fieldData = $sectionData;
             throw new KurogoConfigurationException("Code not written for this type of field");
             break;
         default:
             throw new KurogoConfigurationException("Unable to handle {$type} {$section}. Invalid section type " . $sectionData['sectiontype']);
     }
     if (!isset($fieldData['destinationType'])) {
         throw new KurogoConfigurationException("Unable to determine destination type");
     }
     switch ($fieldData['destinationType']) {
         case 'file':
             if (!isset($fieldData['destinationFile'])) {
                 throw new KurogoConfigurationException("Unable to determine destination location");
             }
             $destination = $fieldData['destinationFile'];
             break;
         case 'folder':
             if (!isset($fieldData['destinationFile'])) {
                 throw new KurogoConfigurationException("Unable to determine destination location");
             }
             if (!isset($fieldData['destinationFolder'])) {
                 throw new KurogoConfigurationException("Unable to determine destination location");
             }
             $destination = rtrim($fieldData['destinationFolder'], '/') . '/' . ltrim($fieldData['destinationFile'], '/');
             break;
     }
     $prefix = isset($fieldData['destinationPrefix']) ? $fieldData['destinationPrefix'] : '';
     if ($prefix && defined($prefix)) {
         $destination = constant($prefix) . '/' . $destination;
     }
     if (isset($fieldData['fileType'])) {
         switch ($fieldData['fileType']) {
             case 'image':
                 $this->setResponseVersion(1);
                 try {
                     $imageData = new ImageProcessor($value['tmp_name']);
                     $transformer = new ImageTransformer($fieldData);
                     $imageType = isset($fieldData['imageType']) ? $fieldData['imageType'] : null;
                     $result = $imageData->transform($transformer, $imageType, $destination);
                     if (KurogoError::isError($result)) {
                         $this->throwError($result);
                     }
                 } catch (KurogoException $e) {
                     throw new KurogoException("Uploaded file must be a valid image (" . $e->getMessage() . ")");
                 }
                 break;
             default:
                 throw new KurogoConfigurationException("Unknown fileType " . $fieldData['fileType']);
         }
     } else {
         if (!move_uploaded_file($value['tmp_name'], $destination)) {
             $this->throwError(new KurogoError(1, "Cannot save file", "Unable to save uploaded file"));
         }
     }
 }
开发者ID:hxfnd,项目名称:Kurogo-Mobile-Web,代码行数:72,代码来源:AdminAPIModule.php


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