本文整理汇总了PHP中Publisher::getMimetypeHandler方法的典型用法代码示例。如果您正苦于以下问题:PHP Publisher::getMimetypeHandler方法的具体用法?PHP Publisher::getMimetypeHandler怎么用?PHP Publisher::getMimetypeHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Publisher
的用法示例。
在下文中一共展示了Publisher::getMimetypeHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: storeUpload
/**
* @param string $post_field
* @param array $allowed_mimetypes
* @param array $errors
*
* @return bool
*/
public function storeUpload($post_field, $allowed_mimetypes = array(), &$errors)
{
$itemid = $this->getVar('itemid');
if (empty($allowed_mimetypes)) {
$allowed_mimetypes = $this->publisher->getMimetypeHandler()->getArrayByType();
}
$maxfilesize = $this->publisher->getConfig('maximum_filesize');
$maxfilewidth = $this->publisher->getConfig('maximum_image_width');
$maxfileheight = $this->publisher->getConfig('maximum_image_height');
if (!is_dir(PublisherUtils::getUploadDir())) {
mkdir(PublisherUtils::getUploadDir(), 0757);
}
$uploader = new XoopsMediaUploader(PublisherUtils::getUploadDir() . '/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
if ($uploader->fetchMedia($post_field)) {
$uploader->setTargetFileName($itemid . "_" . $uploader->getMediaName());
if ($uploader->upload()) {
$this->setVar('filename', $uploader->getSavedFileName());
if ($this->getVar('name') == '') {
$this->setVar('name', $this->getNameFromFilename());
}
$this->setVar('mimetype', $uploader->getMediaType());
return true;
} else {
$errors = array_merge($errors, $uploader->getErrors(false));
return false;
}
} else {
$errors = array_merge($errors, $uploader->getErrors(false));
return false;
}
}