本文整理汇总了PHP中XoopsMediaUploader::getMediaName方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsMediaUploader::getMediaName方法的具体用法?PHP XoopsMediaUploader::getMediaName怎么用?PHP XoopsMediaUploader::getMediaName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XoopsMediaUploader
的用法示例。
在下文中一共展示了XoopsMediaUploader::getMediaName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publisher_pagewrap_upload
/**
* @param $errors
*
* @return bool
*/
function publisher_pagewrap_upload(&$errors)
{
// include_once PUBLISHER_ROOT_PATH . '/class/uploader.php';
xoops_load('XoopsMediaUploader');
$publisher =& PublisherPublisher::getInstance();
$postField = 'fileupload';
$maxFileSize = $publisher->getConfig('maximum_filesize');
$maxImageWidth = $publisher->getConfig('maximum_image_width');
$maxImageHeight = $publisher->getConfig('maximum_image_height');
if (!is_dir(publisherGetUploadDir(true, 'content'))) {
mkdir(publisherGetUploadDir(true, 'content'), 0757);
}
$allowedMimeTypes = array('text/html', 'text/plain', 'application/xhtml+xml');
$uploader = new XoopsMediaUploader(publisherGetUploadDir(true, 'content') . '/', $allowedMimeTypes, $maxFileSize, $maxImageWidth, $maxImageHeight);
if ($uploader->fetchMedia($postField)) {
$uploader->setTargetFileName($uploader->getMediaName());
if ($uploader->upload()) {
return true;
} else {
$errors = array_merge($errors, $uploader->getErrors(false));
return false;
}
} else {
$errors = array_merge($errors, $uploader->getErrors(false));
return false;
}
}
示例2: publisher_pagewrap_upload
function publisher_pagewrap_upload(&$errors)
{
$publisher = Publisher::getInstance();
$post_field = 'fileupload';
$max_size = $publisher->getConfig('maximum_filesize');
$max_imgwidth = $publisher->getConfig('maximum_image_width');
$max_imgheight = $publisher->getConfig('maximum_image_height');
if (!is_dir(PublisherUtils::getUploadDir(true, 'content'))) {
mkdir(PublisherUtils::getUploadDir(true, 'content'), 0757);
}
$allowed_mimetypes = array('text/html', 'text/plain', 'application/xhtml+xml');
$uploader = new XoopsMediaUploader(PublisherUtils::getUploadDir(true, 'content') . '/', $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
if ($uploader->fetchMedia($post_field)) {
$uploader->setTargetFileName($uploader->getMediaName());
if ($uploader->upload()) {
return true;
} else {
$errors = array_merge($errors, $uploader->getErrors(false));
return false;
}
} else {
$errors = array_merge($errors, $uploader->getErrors(false));
return false;
}
}
示例3: storeUpload
function storeUpload($post_field, $response = null, $allowed_mimetypes = null)
{
//global $xoopsModuleConfig, $xoopsUser, $xoopsDB, $xoopsModule;
include_once XHELP_CLASS_PATH . '/uploader.php';
$config =& xhelpGetModuleConfig();
$ticketid = $this->getVar('id');
if (!isset($allowed_mimetypes)) {
$hMime =& xhelpGetHandler('mimetype');
$allowed_mimetypes = $hMime->checkMimeTypes();
if (!$allowed_mimetypes) {
return false;
}
}
$maxfilesize = $config['xhelp_uploadSize'];
$maxfilewidth = $config['xhelp_uploadWidth'];
$maxfileheight = $config['xhelp_uploadHeight'];
if (!is_dir(XHELP_UPLOAD_PATH)) {
mkdir(XHELP_UPLOAD_PATH, 0757);
}
$uploader = new XoopsMediaUploader(XHELP_UPLOAD_PATH . '/', $allowed_mimetypes, $maxfilesize, $maxfilewidth, $maxfileheight);
if ($uploader->fetchMedia($post_field)) {
if (!isset($response)) {
$uploader->setTargetFileName($ticketid . "_" . $uploader->getMediaName());
} else {
$uploader->setTargetFileName($ticketid . "_" . $response . "_" . $uploader->getMediaName());
}
if ($uploader->upload()) {
$hFile =& xhelpGetHandler('file');
$file =& $hFile->create();
$file->setVar('filename', $uploader->getSavedFileName());
$file->setVar('ticketid', $ticketid);
$file->setVar('mimetype', $allowed_mimetypes);
$file->setVar('responseid', isset($response) ? intval($response) : 0);
if ($hFile->insert($file)) {
return $file;
} else {
return $uploader->getErrors();
}
} else {
return $uploader->getErrors();
}
}
}
示例4: smartsection_pagewrap_upload
function smartsection_pagewrap_upload(&$errors)
{
include_once SMARTSECTION_ROOT_PATH . "class/uploader.php";
global $xoopsUser, $xoopsDB, $xoopsModule, $xoopsModule, $xoopsModuleConfig;
include_once SMARTSECTION_ROOT_PATH . 'class/uploader.php';
$config =& smartsection_getModuleConfig();
$post_field = 'fileupload';
//$allowed_mimetypes = '';
// TODO : this needs to be managed by the MimeType section but we need a new parameter for allowed mimetype for pagewrap
/* if(!isset($allowed_mimetypes)){
$hMime =& xoops_getmodulehandler('mimetype');
$allowed_mimetypes = $hMime->checkMimeTypes($post_field);
if(!$allowed_mimetypes){
$errors[] = _SMARTSECTION_MESSAGE_WRONG_MIMETYPE;
return false;
}
}*/
/*$maxfilesize = $config['xhelp_uploadSize'];
$maxfilewidth = $config['xhelp_uploadWidth'];
$maxfileheight = $config['xhelp_uploadHeight'];*/
$max_size = $xoopsModuleConfig['maximum_filesize'];
$max_imgwidth = $xoopsModuleConfig['maximum_image_width'];
$max_imgheight = $xoopsModuleConfig['maximum_image_height'];
if (!is_dir(smartsection_getUploadDir(true, 'content'))) {
mkdir(smartsection_getUploadDir(true, 'content'), 0757);
}
$allowed_mimetypes = array('text/html', 'text/plain', 'application/xhtml+xml');
$uploader = new XoopsMediaUploader(smartsection_getUploadDir(true, 'content') . '/', $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight);
if ($uploader->fetchMedia($post_field)) {
$uploader->setTargetFileName($uploader->getMediaName());
if ($uploader->upload()) {
return true;
} else {
$errors = array_merge($errors, $uploader->getErrors(false));
return false;
}
} else {
$errors = array_merge($errors, $uploader->getErrors(false));
return false;
}
}
示例5: 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);
}
示例6: foreach
$tpl->setVar('tpl_source', $fsource, true);
@unlink($uploader->getSavedDestination());
if (!$tpltpl_handler->insert($tpl)) {
$msg[] = 'Failed inserting data for ' . $upload_file . ' to database';
} else {
$msg[] = 'Template file <b>' . $upload_file . '</b> updated.';
if ($tplset == $xoopsConfig['template_set']) {
include_once XOOPS_ROOT_PATH . '/class/template.php';
if (xoops_template_touch($tpl->getVar('tpl_id'), true)) {
$msg[] = 'Template file <b>' . $upload_file . '</b> compiled.';
}
}
}
}
} else {
if ($uploader->getMediaName() == '') {
continue;
} else {
$msg[] = $uploader->getErrors();
}
}
}
xoops_cp_header();
echo '<code>';
foreach ($msg as $m) {
echo $m . '<br />';
}
echo '</code><br /><a href="admin.php?fct=tplsets&op=listtpl&tplset=' . $tplset . '&moddir=' . $moddir . '">' . _MD_AM_BTOTADMIN . '</a>';
xoops_cp_footer();
break;
case 'importtpl':
示例7: 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;
}
}
示例8: isset
$HotelObj->setVar('hotel_tags', isset($_POST['hotel_tags']) ? addslashes($_POST['hotel_tags']) : '');
$HotelObj->setVar('hotel_description', isset($_POST['hotel_description']) ? addslashes($_POST['hotel_description']) : '');
$HotelObj->setVar('hotel_star', isset($_POST['hotel_star']) ? intval($_POST['hotel_star']) : 0);
$HotelObj->setVar('hotel_address', isset($_POST['hotel_address']) ? addslashes($_POST['hotel_address']) : '');
$HotelObj->setVar('hotel_telephone', isset($_POST['hotel_telephone']) ? addslashes($_POST['hotel_telephone']) : '');
$HotelObj->setVar('hotel_fax', isset($_POST['hotel_fax']) ? addslashes($_POST['hotel_fax']) : '');
$HotelObj->setVar('hotel_room_count', isset($_POST['hotel_room_count']) ? intval($_POST['hotel_room_count']) : 0);
//file upload
$hotel_icon = isset($_POST['hotel_icon_old']) ? $_POST['hotel_icon_old'] : null;
include XOOPS_ROOT_PATH . '/class/uploader.php';
if (!empty($_FILES['hotel_icon']['tmp_name'])) {
$path = MARTIN_ROOT_PATH . '/images/hotelicon/';
$FileTypeUpload = array("image/jpg", "image/png", "image/gif", "image/jpeg");
$uploader = new XoopsMediaUploader($path, $FileTypeUpload, 2048 * 1024);
if ($uploader->fetchMedia($_POST["xoops_upload_file"][0])) {
$uploader->ext = strtolower(ltrim(strrchr($uploader->getMediaName(), '.'), '.'));
$SaveFileName = time() . rand(1000, 10000) . "." . $uploader->ext;
$uploader->setTargetFileName($SaveFileName);
if (!$uploader->upload()) {
xoops_error($uploader->getErrors());
exit;
} elseif (file_exists($uploader->getSavedDestination())) {
//delete images
if (!empty($hotel_icon)) {
unlink(MARTIN_ROOT_PATH . '/images/hotelicon/' . $hotel_icon);
}
$hotel_icon = $uploader->getSavedFileName();
}
} else {
xoops_error($uploader->getErrors());
}
示例9: XoopsMediaUploader
}
$allowed_mimetypes = $att_handler->getTypes();
$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);
示例10: stripslashes
if (isset($_POST['xoops_upload_file'])) {
$fldname = $_FILES[$_POST['xoops_upload_file'][0]];
$fldname = get_magic_quotes_gpc() ? stripslashes($fldname['name']) : $fldname['name'];
if (xoops_trim($fldname != '')) {
$sfiles = new sFiles();
$destname = $sfiles->createUploadName(XOOPS_UPLOAD_PATH, $fldname);
/**
* You can attach files to your news
*/
$permittedtypes = explode("\n", str_replace("\r", '', news_getmoduleoption('mimetypes')));
array_walk($permittedtypes, 'trim');
$uploader = new XoopsMediaUploader(XOOPS_UPLOAD_PATH, $permittedtypes, $xoopsModuleConfig['maxuploadsize']);
$uploader->setTargetFileName($destname);
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
if ($uploader->upload()) {
$sfiles->setFileRealName($uploader->getMediaName());
$sfiles->setStoryid($story->storyid());
$sfiles->setMimetype($sfiles->giveMimetype(XOOPS_UPLOAD_PATH . '/' . $uploader->getMediaName()));
$sfiles->setDownloadname($destname);
if (!$sfiles->store()) {
echo _AM_UPLOAD_DBERROR_SAVE;
}
} else {
echo _AM_UPLOAD_ERROR . ' ' . $uploader->getErrors();
}
} else {
echo $uploader->getErrors();
}
}
}
}
示例11: 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;
}
}
示例12: array
$extendmimetypes = array('rar' => 'application/octet-stream');
$maxfilesize = 50000000;
$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);
}
}
}
示例13: stripslashes
if(isset($_POST['xoops_upload_file'])) {
$fldname = $_FILES[$_POST['xoops_upload_file'][0]];
$fldname = (get_magic_quotes_gpc()) ? stripslashes($fldname['name']) : $fldname['name'];
if(xoops_trim($fldname!='')) {
$sfiles = new nw_sFiles();
$destname=$sfiles->createUploadName(NW_ATTACHED_FILES_PATH,$fldname);
/**
* You can attach files to your news
*/
$permittedtypes = explode("\n",str_replace("\r",'',nw_getmoduleoption('mimetypes', NW_MODULE_DIR_NAME)));
array_walk($permittedtypes, 'trim');
$uploader = new XoopsMediaUploader( NW_ATTACHED_FILES_PATH, $permittedtypes, $xoopsModuleConfig['maxuploadsize']);
$uploader->setTargetFileName($destname);
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
if ($uploader->upload()) {
$sfiles->setFileRealName($uploader->getMediaName());
$sfiles->setStoryid($story->storyid());
$sfiles->setMimetype($sfiles->giveMimetype(NW_ATTACHED_FILES_PATH.'/'.$uploader->getMediaName()));
$sfiles->setDownloadname($destname);
if(!$sfiles->store()) {
echo _AM_NW_UPLOAD_DBERROR_SAVE;
}
} else {
echo _AM_NW_UPLOAD_ERROR. ' ' . $uploader->getErrors();
}
} else {
echo $uploader->getErrors();
}
}
}
}