Ejemplo n.º 1
0
 /**
  * Uploads the selected images
  *
  * @return  void
  * @since   3.0
  */
 public function upload()
 {
     $result = array('error' => false);
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/upload.php';
     $uploader = new JoomUpload();
     if ($image = $uploader->upload(JRequest::getCmd('type', 'ajax'))) {
         $result['success'] = true;
         if (is_object($image)) {
             $result['id'] = $image->id;
             $result['imgtitle'] = $image->imgtitle;
             $result['thumbnailUrl'] = JoomAmbit::getInstance()->getImg('thumb_url', $image);
         }
     } else {
         if ($error = $uploader->getError()) {
             $result['error'] = $error;
         } else {
             $result['error'] = JText::_('COM_JOOMGALLERY_UPLOAD_ERROR_FILE_NOT_UPLOADED');
         }
     }
     if ($debug_output = $uploader->getDebugOutput()) {
         $result['debug_output'] = $debug_output;
     }
     $doc = JFactory::getDocument();
     $doc->setMimeEncoding('text/plain');
     echo json_encode($result);
 }