本文整理汇总了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);
}
示例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);
}