本文整理匯總了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;
}
}