本文整理汇总了PHP中MediaHelper::createthumb方法的典型用法代码示例。如果您正苦于以下问题:PHP MediaHelper::createthumb方法的具体用法?PHP MediaHelper::createthumb怎么用?PHP MediaHelper::createthumb使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MediaHelper
的用法示例。
在下文中一共展示了MediaHelper::createthumb方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: uploadImage
function uploadImage()
{
$mainframe = JFactory::getApplication();
// Check for request forgeries
JRequest::checkToken('request') or jexit('Invalid Token');
$file = JRequest::getVar('photo_path', '', 'files', 'array');
$folder = JRequest::getVar('folder', '', '', 'path');
$format = JRequest::getVar('format', 'html', '', 'cmd');
$return = JRequest::getVar('return-url', null, 'post', 'base64');
$err = null;
// Set FTP credentials, if given
jimport('joomla.client.helper');
JClientHelper::setCredentialsFromRequest('ftp');
require_once JPATH_COMPONENT . DS . 'helpers' . DS . 'media.php';
// Make the filename safe
jimport('joomla.filesystem.file');
$file['name'] = JFile::makeSafe($file['name']);
if (isset($file['name'])) {
$filepath = JPath::clean(COM_WEBMAPPLUS_MEDIA_BASE . DS . $folder . DS . strtolower($file['name']));
if (!MediaHelper::canUpload($file, $err)) {
if ($format == 'json') {
jimport('joomla.error.log');
$log =& JLog::getInstance('upload.error.php');
$log->addEntry(array('comment' => 'Invalid: ' . $filepath . ': ' . $err));
header('HTTP/1.0 415 Unsupported Media Type');
jexit('Error. Unsupported Media Type!');
} else {
JError::raiseNotice(100, JText::_($err));
// REDIRECT
if ($return) {
$mainframe->redirect(base64_decode($return) . '&folder=' . $folder);
}
return;
}
}
if (JFile::exists($filepath)) {
if ($format == 'json') {
jimport('joomla.error.log');
$log =& JLog::getInstance('upload.error.php');
$log->addEntry(array('comment' => 'File already exists: ' . $filepath));
header('HTTP/1.0 409 Conflict');
jexit('Error. File already exists');
} else {
JError::raiseNotice(100, JText::_('Error. File already exists'));
// REDIRECT
if ($return) {
$mainframe->redirect(base64_decode($return) . '&folder=' . $folder);
}
return;
}
}
if (!JFile::upload($file['tmp_name'], $filepath)) {
if ($format == 'json') {
jimport('joomla.error.log');
$log =& JLog::getInstance('upload.error.php');
$log->addEntry(array('comment' => 'Cannot upload: ' . $filepath));
header('HTTP/1.0 400 Bad Request');
jexit('Error. Unable to upload file');
} else {
JError::raiseWarning(100, JText::_('Error. Unable to upload file'));
// REDIRECT
if ($return) {
$mainframe->redirect(base64_decode($return) . '&folder=' . $folder);
}
return;
}
} else {
if ($format == 'json') {
jimport('joomla.error.log');
$log =& JLog::getInstance();
$log->addEntry(array('comment' => $folder));
jexit('Upload complete');
} else {
$mainframe->enqueueMessage(JText::_('Upload complete'));
// REDIRECT
if ($return) {
$mainframe->redirect(base64_decode($return) . '&folder=' . $folder);
}
$params =& JComponentHelper::getParams('com_webmapplus');
$height = $params->get('picture_height');
$width = $params->get('picture_width');
MediaHelper::createthumb($filepath, $filepath, $width, $height);
$filepath = str_replace(JPATH_ROOT, "", $filepath);
$file_information = pathinfo($filepath);
return $file_information['basename'];
}
}
} else {
$mainframe->redirect('index.php', 'Invalid Request', 'error');
}
}