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