コード例 #1
0
 public function upload()
 {
     // Check for token
     JSession::checkToken() or K2Response::throwError(JText::_('JINVALID_TOKEN'));
     // Get user
     $user = JFactory::getUser();
     // Permissions check
     if (!$user->authorise('k2.item.create', 'com_k2') && !$user->authorise('k2.item.edit', 'com_k2') && !$user->authorise('k2.item.edit.own', 'com_k2')) {
         K2Response::throwError(JText::_('K2_YOU_ARE_NOT_AUTHORIZED_TO_PERFORM_THIS_OPERATION'), 403);
     }
     // Get input
     $upload = $this->input->get('upload', '', 'cmd');
     $url = $this->input->get('url', '', 'string');
     $file = $this->input->files->get('file');
     // Upload media using helper
     $media = K2HelperMedia::add($file, $url, $upload);
     echo json_encode($media);
     // Return
     return $this;
 }
コード例 #2
0
ファイル: items.php プロジェクト: Naldo100/k2-v3-dev-build
 /**
  * Close method.
  *
  * @return boolean	True on success false on failure.
  */
 public function close()
 {
     // Clean up any temporary images and files
     K2HelperImages::purge('item');
     K2HelperGalleries::purge();
     K2HelperMedia::purge();
     K2HelperAttachments::purge();
     return true;
 }