本文整理汇总了PHP中XoopsMediaUploader::getMediaType方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsMediaUploader::getMediaType方法的具体用法?PHP XoopsMediaUploader::getMediaType怎么用?PHP XoopsMediaUploader::getMediaType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsMediaUploader
的用法示例。
在下文中一共展示了XoopsMediaUploader::getMediaType方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFile
function createFile($eventId)
{
$userId = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getVar('uid') : 0;
$allowedMimeType = array();
$mimeType = (include XOOPS_ROOT_PATH . '/class/mimetypes.inc.php');
foreach ($GLOBALS['xoopsModuleConfig']['allowed_file_extention'] as $fileExt) {
$allowedMimeType[] = $mimeType[$fileExt];
}
$uploader = new XoopsMediaUploader(XOOPS_ROOT_PATH . '/uploads/extcal', $allowedMimeType, 3145728);
$uploader->setPrefix($userId . '-' . $eventId . '_');
if ($uploader->fetchMedia('event_file')) {
if (!$uploader->upload()) {
return false;
}
} else {
return false;
}
$data = array('file_name' => $uploader->getSavedFileName(), 'file_nicename' => $uploader->getMediaName(), 'file_mimetype' => $uploader->getMediaType(), 'file_size' => $_FILES['event_file']['size'], 'file_date' => time(), 'file_approved' => 1, 'event_id' => $eventId, 'uid' => $userId);
$file = $this->create();
$file->setVars($data);
return $this->insert($file);
}
示例2:
$obj->setVars($_POST);
if (preg_match('/^\\d+$/', $_POST["avatar_weight"]) == false) {
$error_msg .= XoopsLocale::E_YOU_NEED_A_POSITIVE_INTEGER . '<br />';
$obj->setVar("avatar_weight", 0);
} else {
$obj->setVar("avatar_weight", Request::getInt('avatar_weight', 0));
}
$obj->setVar('avatar_type', 'C');
if ($uploader_avatars_img->fetchMedia('avatar_file')) {
$uploader_avatars_img->setPrefix('savt');
$uploader_avatars_img->fetchMedia('avatar_file');
if (!$uploader_avatars_img->upload()) {
$error_msg .= $uploader_avatars_img->getErrors();
$obj->setVar('avatar_file', 'avatars/blank.gif');
} else {
$obj->setVar('avatar_mimetype', $uploader_avatars_img->getMediaType());
$obj->setVar('avatar_file', 'avatars/' . $uploader_avatars_img->getSavedFileName());
}
} else {
$file = Request::getString('avatar_file', 'blank.gif');
$obj->setVar('avatar_file', 'avatars/' . $file);
}
if ($error_msg == '') {
if ($avatar_Handler->insert($obj)) {
$xoops->redirect('avatar_custom.php', 2, XoopsLocale::S_ITEM_SAVED);
}
$error_msg .= $obj->getHtmlErrors();
}
$admin_page->addItemButton(AvatarsLocale::LIST_OF_AVATARS, 'avatar_custom.php', 'application-view-detail');
$admin_page->renderButton();
$xoops->tpl()->assign('info_msg', $xoops->alert('info', $info_msg, XoopsLocale::INFORMATION_FOR_UPLOADS));
示例3: XoopsMediaUploader
}
include_once XOOPS_ROOT_PATH . '/class/uploader.php';
$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/bmp'), $imagecategory->getVar('imgcat_maxsize'), $imagecategory->getVar('imgcat_maxwidth'), $imagecategory->getVar('imgcat_maxheight'));
$uploader->setPrefix('img');
$err = array();
$ucount = count($_POST['xoops_upload_file']);
for ($i = 0; $i < $ucount; $i++) {
if ($uploader->fetchMedia($_POST['xoops_upload_file'][$i])) {
if (!$uploader->upload()) {
$err[] = $uploader->getErrors();
} else {
$image_handler =& xoops_gethandler('image');
$image =& $image_handler->create();
$image->setVar('image_name', $uploader->getSavedFileName());
$image->setVar('image_nicename', $image_nicename);
$image->setVar('image_mimetype', $uploader->getMediaType());
$image->setVar('image_created', time());
$image_display = empty($image_display) ? 0 : 1;
$image->setVar('image_display', $image_display);
$image->setVar('image_weight', $image_weight);
$image->setVar('imgcat_id', $imgcat_id);
if ($imagecategory->getVar('imgcat_storetype') == 'db') {
$fp = @fopen($uploader->getSavedDestination(), 'rb');
$fbinary = @fread($fp, filesize($uploader->getSavedDestination()));
@fclose($fp);
$image->setVar('image_body', $fbinary, true);
@unlink($uploader->getSavedDestination());
}
if (!$image_handler->insert($image)) {
$err[] = sprintf(_FAILSAVEIMG, $image->getVar('image_nicename'));
}
示例4: XoopsMediaUploader
exit;
}
if ($myxoopsConfigUser['avatar_allow_upload'] == 1 && $u_obj->getVar('posts', 's') >= $myxoopsConfigUser['avatar_minposts']) {
include_once XOOPS_ROOT_PATH . '/class/uploader.php';
$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'), $myxoopsConfigUser['avatar_maxsize'], $myxoopsConfigUser['avatar_width'], $myxoopsConfigUser['avatar_height']);
$uploader->setAllowedExtensions(array('gif', 'jpeg', 'jpg', 'png'));
$xoops_upload_file = $formdata->getValueArray('post', 'xoops_upload_file', 's', true);
if ($uploader->fetchMedia($xoops_upload_file[0])) {
$uploader->setPrefix('cavt');
if ($uploader->upload()) {
$avt_handler =& xoops_gethandler('avatar');
$avatar =& $avt_handler->create();
$avatar->setVar('avatar_file', $uploader->getSavedFileName());
$avatar->setVar('avatar_name', $u_obj->getVar('uname', 'n'), true);
// not gpc
$avatar->setVar('avatar_mimetype', $uploader->getMediaType());
$avatar->setVar('avatar_display', 1);
$avatar->setVar('avatar_type', 'C');
if (!$avt_handler->insert($avatar)) {
@unlink($uploader->getSavedDestination());
} else {
$oldavatar = $u_obj->getVar('user_avatar', 's');
if (!empty($oldavatar) && $oldavatar != 'blank.gif' && !preg_match('/^savt/', strtolower($oldavatar))) {
$avatars =& $avt_handler->getObjects(new Criteria('avatar_file', $oldavatar));
$avt_handler->delete($avatars[0]);
$oldavatar_path = str_replace("\\", '/', realpath(XOOPS_UPLOAD_PATH . '/' . $oldavatar));
if (0 === strpos($oldavatar_path, XOOPS_UPLOAD_PATH) && is_file($oldavatar_path)) {
unlink($oldavatar_path);
}
}
$u_obj->setVar('user_avatar', $uploader->getSavedFileName(), true);
示例5: 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;
}
}
示例6: XoopsMediaUploader
}
include_once XOOPS_ROOT_PATH . "/class/uploader.php";
$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array("image/gif", "image/jpeg", "image/pjpeg", "image/x-png", "image/png", "image/bmp"), $imgcat->getVar("imgcat_maxsize"), $imgcat->getVar("imgcat_maxwidth"), $imgcat->getVar("imgcat_maxheight"));
$uploader->setPrefix("img");
$err = array();
$ucount = count($_POST["xoops_upload_file"]);
for ($i = 0; $i < $ucount; $i++) {
if ($uploader->fetchMedia($_POST["xoops_upload_file"][$i])) {
if (!$uploader->upload()) {
$err[] = $uploader->getErrors();
} else {
$image_handler =& xoops_gethandler("image");
$image =& $image_handler->create();
$image->setVar("image_name", $uploader->getSavedFileName());
$image->setVar("image_nicename", $image_nicename);
$image->setVar("image_mimetype", $uploader->getMediaType());
$image->setVar("image_created", time());
$image_display = empty($image_display) ? 0 : 1;
$image->setVar("image_display", $image_display);
$image->setVar("image_weight", $image_weight);
$image->setVar("imgcat_id", $imgcat_id);
if ($imgcat->getVar("imgcat_storetype") == "db") {
$fp = @fopen($uploader->getSavedDestination(), "rb");
$fbinary = @fread($fp, filesize($uploader->getSavedDestination()));
@fclose($fp);
$image->setVar("image_body", $fbinary, true);
@unlink($uploader->getSavedDestination());
}
if (!$image_handler->insert($image)) {
$err[] = sprintf(_FAILSAVEIMG, $image->getVar("image_nicename"));
}
示例7: XoopsMediaUploader
$maxfilesize = 50000000;
$uploader = new XoopsMediaUploader($files_dir, $allowed_mimetypes, $maxfilesize);
foreach ($_POST["xoops_upload_file"] as $k => $v) {
if ($uploader->fetchMedia($v)) {
$uploader->setPrefix('support_');
if (!$uploader->upload()) {
echo $uploader->getErrors();
} else {
$att_obj =& $att_handler->create();
$att_obj->setVar('res_id', $res_id);
if (!empty($xoopsUser)) {
$att_obj->setVar('uid', $xoopsUser->getVar("uid"));
}
$att_obj->setVar("att_filename", $uploader->getMediaName());
$att_obj->setVar("att_attachment", $uploader->getSavedFileName());
$att_obj->setVar("att_type", $uploader->getMediaType());
$att_obj->setVar("att_size", $uploader->getMediaSize());
$att_obj->setVar("grate_time", time());
$att_obj->setVar("update_time", time());
$att_handler->insert($att_obj);
$att_num = $att_num + 1;
}
unset($att_obj);
}
}
//update resources res_attachment
$res_obj =& $resources_handler->get($res_id);
$res_obj->setVar('res_attachment', $att_num);
$resources_handler->insert($res_obj);
}
redirect_header('admin.resources.php', 3, '保存成功');
示例8: storeUpload
function storeUpload($post_field, $allowed_mimetypes = null, &$errors)
{
global $xoopsUser, $xoopsDB, $xoopsModule;
include_once SMARTPARTNER_ROOT_PATH . 'class/uploader.php';
$config =& smartpartner_getModuleConfig();
$id = $this->getVar('id');
if (!isset($allowed_mimetypes)) {
$hMime =& xoops_getmodulehandler('mimetype');
$allowed_mimetypes = $hMime->checkMimeTypes($post_field);
if (!$allowed_mimetypes) {
return false;
}
}
/*$maxfilesize = $config['xhelp_uploadSize'];
$maxfilewidth = $config['xhelp_uploadWidth'];
$maxfileheight = $config['xhelp_uploadHeight'];*/
$maxfilesize = $config['maximum_filesize'];
$maxfilewidth = 100000;
//$config['maximum_image_width'];
$maxfileheight = 100000;
//$config['maximum_image_height'];
if (!is_dir(smartpartner_getUploadDir())) {
mkdir(smartpartner_getUploadDir(), 0757);
}
$uploader = new XoopsMediaUploader(smartpartner_getUploadDir() . '/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
if ($uploader->fetchMedia($post_field)) {
$file_title = $this->purifyText($uploader->getMediaName());
$uploader->setTargetFileName($id . "_" . $file_title);
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;
}
}
示例9: XoopsMediaUploader
$maxfilewidth = 1200;
$maxfileheight = 1200;
$uploader = new XoopsMediaUploader($files_dir, $allowed_mimetypes, $maxfilesize, null, null, $extendmimetypes);
foreach ($_POST["xoops_upload_file"] as $k => $v) {
if ($uploader->fetchMedia($v)) {
$uploader->setPrefix('support_');
if (!$uploader->upload()) {
echo $uploader->getErrors();
} else {
$annex_obj =& $annex_handler->create();
$annex_obj->setVar('pro_id', $pro_id);
$annex_obj->setVar('tran_id', $tran_id);
$annex_obj->setVar('uid', $user['uid']);
$annex_obj->setVar('annex_title', $uploader->getMediaName());
$annex_obj->setVar('annex_file', $uploader->getSavedFileName());
$annex_obj->setVar('annex_type', $uploader->getMediaType());
$annex_handler->insert($annex_obj);
// thumbs
/*
if(in_array($uploader->getMediaType(), $allowed_mimetypes)) {
setImageThumb($files_dir."/", $uploader->getSavedFileName(), $files_dir."/", 'mid_'.$uploader->getSavedFileName(), array($mid_wh[0], $mid_wh[1]));
setImageThumb($files_dir."/", $uploader->getSavedFileName(), $files_dir."/", 'thumb_'.$uploader->getSavedFileName(), array($thumb_wh[0], $thumb_wh[1]));
}
*/
}
unset($annex_obj);
}
}
}
}
if ($op == 'forword' && $user['level'] == 'support') {
示例10: dispatch
function dispatch()
{
if($this->isGuest()){
redirect_header(XOOPS_URL, 2, _NOPERM);
}
require XSNS_FRAMEWORK_DIR.'/global.php';
require_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
require_once XOOPS_ROOT_PATH.'/language/'.$xoopsConfig['language'].'/user.php';
if (!$this->validateToken('upload')) {
redirect_header(XSNS_URL_MYPAGE_PROFILE, 3, _US_NOEDITRIGHT);
}
$config_handler =& xoops_gethandler('config');
if(defined('XOOPS_CUBE_LEGACY')){
$xoopsConfigUser =& $config_handler->getConfigsByDirname('user');
}
else{
$xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
}
$xoops_upload_file = array();
$uid = 0;
if (!empty($_POST['xoops_upload_file']) && is_array($_POST['xoops_upload_file'])){
$xoops_upload_file = $_POST['xoops_upload_file'];
}
if (!empty($_POST['uid'])) {
$uid = intval($_POST['uid']);
}
if (empty($uid) || $xoopsUser->getVar('uid') != $uid ) {
redirect_header(XSNS_URL_MYPAGE_PROFILE, 3, _US_NOEDITRIGHT);
}
if ($xoopsConfigUser['avatar_allow_upload'] == 1 && $xoopsUser->getVar('posts') >= $xoopsConfigUser['avatar_minposts']) {
require_once XOOPS_ROOT_PATH.'/class/uploader.php';
$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, array('image/gif', 'image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png'), $xoopsConfigUser['avatar_maxsize'], $xoopsConfigUser['avatar_width'], $xoopsConfigUser['avatar_height']);
$uploader->setAllowedExtensions(array('gif', 'jpeg', 'jpg', 'png'));
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
$uploader->setPrefix('cavt');
if ($uploader->upload()) {
$avt_handler =& xoops_gethandler('avatar');
$avatar =& $avt_handler->create();
$avatar->setVar('avatar_file', $uploader->getSavedFileName());
$avatar->setVar('avatar_name', $xoopsUser->getVar('uname'));
$avatar->setVar('avatar_mimetype', $uploader->getMediaType());
$avatar->setVar('avatar_display', 1);
$avatar->setVar('avatar_type', 'C');
if (!$avt_handler->insert($avatar)) {
@unlink($uploader->getSavedDestination());
}
else {
$oldavatar = $xoopsUser->getVar('user_avatar');
if (!empty($oldavatar) && $oldavatar != 'blank.gif' && !preg_match("/^savt/", strtolower($oldavatar))) {
$avatars =& $avt_handler->getObjects(new Criteria('avatar_file', $oldavatar));
$avt_handler->delete($avatars[0]);
$oldavatar_path = str_replace("\\", "/", realpath(XOOPS_UPLOAD_PATH.'/'.$oldavatar));
if (0 === strpos($oldavatar_path, XOOPS_UPLOAD_PATH) && is_file($oldavatar_path)) {
unlink($oldavatar_path);
}
}
$sql = sprintf("UPDATE %s SET user_avatar = %s WHERE uid = %u", $this->db->prefix('users'), $this->db->quoteString($uploader->getSavedFileName()), $xoopsUser->getVar('uid'));
$this->db->query($sql);
$avt_handler->addUser($avatar->getVar('avatar_id'), $xoopsUser->getVar('uid'));
redirect_header(XSNS_URL_MYPAGE_PROFILE, 2, _US_PROFUPDATED);
}
}
}
redirect_header(XSNS_URL_MYPAGE_PROFILE, 2, _MD_XSNS_PROFILE_AVATAR_UPLOAD_NG);
}
redirect_header(XSNS_URL_MYPAGE_PROFILE, 2, _MD_XSNS_PROFILE_AVATAR_UPLOAD_NG);
}
示例11:
if ($uploader->fetchMedia($filename) && $uploader->upload()) {
if (!$xoopsUser) {
if ($xoopsModuleConfig['anonpost'] == 1) {
$uid = 0;
} else {
redirect_header("index.php", 3, _NOPERM);
exit;
}
} else {
$uid = $xoopsUser->uid();
}
$fileObj = $smartsection_file_handler->create();
$fileObj->setVar('name', $_POST['name']);
$fileObj->setVar('description', $_POST['description']);
$fileObj->setVar('filename', $uploader->getSavedFileName());
$fileObj->setVar('mimetype', $uploader->getMediaType());
$fileObj->setVar('uid', $uid);
$fileObj->setVar('itemid', $itemid);
// Storing the file
if (!$fileObj->store()) {
redirect_header("javascript:history.go(-1)", 3, _AM_SS_FILEUPLOAD_ERROR . ss_formatErrors($fileObj->getErrors()));
exit;
}
redirect_header("item.php?op=mod&itemid=" . $fileObj->itemid(), 2, _AM_SS_FILEUPLOAD_SUCCESS);
} else {
echo _AM_SS_FILEUPLOAD_ERROR . $uploader->getErrors();
}
}
exit;
break;
case "mod":