当前位置: 首页>>代码示例>>PHP>>正文


PHP MediaHelper::createthumb方法代码示例

本文整理汇总了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');
     }
 }
开发者ID:notWood,项目名称:webmapplus,代码行数:91,代码来源:location.php


注:本文中的MediaHelper::createthumb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。