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


PHP api_Utils::GetFileExtension方法代码示例

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


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

示例1: UploadContacts

 /**
  * @return array
  */
 public function UploadContacts()
 {
     $oAccount = $this->getDefaultAccountFromParam();
     if (!$this->oApiCapability->isPersonalContactsSupported($oAccount)) {
         throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::ContactsNotAllowed);
     }
     $aFileData = $this->getParamValue('FileData', null);
     $sAdditionalData = $this->getParamValue('AdditionalData', '{}');
     $aAdditionalData = @json_decode($sAdditionalData, true);
     $sError = '';
     $aResponse = array('ImportedCount' => 0, 'ParsedCount' => 0);
     if (is_array($aFileData)) {
         $sFileType = strtolower(\api_Utils::GetFileExtension($aFileData['name']));
         $bIsCsvVcfExtension = $sFileType === 'csv' || $sFileType === 'vcf';
         if ($bIsCsvVcfExtension) {
             $sSavedName = 'import-post-' . md5($aFileData['name'] . $aFileData['tmp_name']);
             if ($this->ApiFileCache()->moveUploadedFile($oAccount, $sSavedName, $aFileData['tmp_name'])) {
                 $oApiContactsManager = $this->ApiContacts();
                 if ($oApiContactsManager) {
                     $iParsedCount = 0;
                     $iImportedCount = $oApiContactsManager->import($oAccount->IdUser, $sFileType, $this->ApiFileCache()->generateFullFilePath($oAccount, $sSavedName), $iParsedCount, $iGroupId = $aAdditionalData['GroupId'], $bIsShared = $aAdditionalData['IsShared']);
                 }
                 if (false !== $iImportedCount && -1 !== $iImportedCount) {
                     $aResponse['ImportedCount'] = $iImportedCount;
                     $aResponse['ParsedCount'] = $iParsedCount;
                 } else {
                     $sError = 'unknown';
                 }
                 $this->ApiFileCache()->clear($oAccount, $sSavedName);
             } else {
                 $sError = 'unknown';
             }
         } else {
             throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::IncorrectFileExtension);
         }
     } else {
         $sError = 'unknown';
     }
     if (0 < strlen($sError)) {
         $aResponse['Error'] = $sError;
     }
     return $this->DefaultResponse($oAccount, __FUNCTION__, $aResponse);
 }
开发者ID:nsine,项目名称:webmail-lite,代码行数:46,代码来源:Actions.php

示例2: UploadContacts

 /**
  * @return array
  */
 public function UploadContacts()
 {
     $oAccount = $this->getDefaultAccountFromParam();
     if (!$this->oApiCapability->IsPersonalContactsSupported($oAccount)) {
         throw new \ProjectSeven\Exceptions\ClientException(\ProjectSeven\Notifications::ContactsNotAllowed);
     }
     $aFileData = $this->getParamValue('FileData', null);
     $sError = '';
     $aResponse = array('ImportedCount' => 0, 'ParsedCount' => 0);
     if (is_array($aFileData)) {
         $sSavedName = 'import-post-' . md5($aFileData['name'] . $aFileData['tmp_name']);
         if ($this->ApiFileCache()->MoveUploadedFile($oAccount, $sSavedName, $aFileData['tmp_name'])) {
             $oApiContactsManager = $this->ApiContacts();
             if ($oApiContactsManager) {
                 $iParsedCount = 0;
                 $sFileType = \api_Utils::GetFileExtension($aFileData['name']);
                 $iImportedCount = $oApiContactsManager->Import($oAccount->IdUser, $sFileType, $this->ApiFileCache()->GenerateFullFilePath($oAccount, $sSavedName), $iParsedCount);
             }
             if (false !== $iImportedCount && -1 !== $iImportedCount) {
                 $aResponse['ImportedCount'] = $iImportedCount;
                 $aResponse['ParsedCount'] = $iParsedCount;
             } else {
                 $sError = 'unknown';
             }
             $this->ApiFileCache()->Clear($oAccount, $sSavedName);
         } else {
             $sError = 'unknown';
         }
     } else {
         $sError = 'unknown';
     }
     if (0 < strlen($sError)) {
         $aResponse['Error'] = $sError;
     }
     return $this->DefaultResponse($oAccount, 'UploadContacts', $aResponse);
 }
开发者ID:hallnewman,项目名称:webmail-lite,代码行数:39,代码来源:Actions.php


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