Example #1
0
 /**
  * Upload image
  *
  * @return bool
  */
 public function image_upload()
 {
     $image = $this->_validation();
     try {
         if ($image->check()) {
             // Create new filename
             $this->_newfilename = File::create_filename($image[$this->_config['fn']]['name']);
             if ($this->_config['action'] == 'add') {
                 $id = $this->_image_upload_add();
             } else {
                 $id = $this->_image_upload_edit();
             }
             // Data for template
             $this->_data = array('id' => $id, 'fn' => $this->_config['fn'], 'url' => $this->_config['url'] . $this->_newfilename, 'b_url' => $this->_config['b_url'] . $this->_newfilename, 'group' => $this->_config['group']);
             return TRUE;
         } else {
             $error = $image->errors('upload');
             $this->_error = $error[$this->_config['fn']];
             return FALSE;
         }
     } catch (Exception $e) {
         $this->_error = $e->getMessage();
         return FALSE;
     }
 }