當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。