Welcome Guest, Not a member yet? Register   Sign In
Validation file input and text input
#10

[eluser]cyberjunkie[/eluser]
for some reason it's not displaying form errors...

Code:
function _do_upload()
{
  $username = $this->tank_auth->get_username();
  
  $config['upload_path'] = './uploads/avatars/';
  $config['allowed_types'] = 'jpg|png';
  $config['file_name'] = $username . '_avatar';
  $config['overwrite'] = TRUE; //overwrite user avatar
  $config['max_size'] = '800'; //in KB

  $this->load->library('upload', $config);

  if (! $this->upload->do_upload())
  {
   $this->form_validation->set_message('_do_upload', $this->upload->display_errors());
   return FALSE;
  }
return TRUE
}

function

Code:
function upload_avatar()
{
  $this->form_validation->set_rules('userfile', 'File', 'callback__do_upload');

  if ($this->form_validation->run() == FALSE)
  {
   //load view
   $this->template->build('member/settings/upload_avatar');
  
  }
  else
  {
   //Add image path to database
                        $avatar = $this->upload->file_name; //out of scope
   $user_id = $this->tank_auth->get_user_id();
   $this->Settings_model->update_avatar($avatar, $user_id);
   $this->session->set_flashdata('success', 'Profile image uploaded!');
  
   redirect('/settings/crop_avatar');
  }
  
  
    }


Messages In This Thread
Validation file input and text input - by El Forum - 07-09-2012, 11:17 AM
Validation file input and text input - by El Forum - 07-10-2012, 01:23 AM
Validation file input and text input - by El Forum - 07-10-2012, 02:11 AM
Validation file input and text input - by El Forum - 07-10-2012, 12:03 PM
Validation file input and text input - by El Forum - 07-10-2012, 12:22 PM
Validation file input and text input - by El Forum - 07-11-2012, 01:44 AM
Validation file input and text input - by El Forum - 07-11-2012, 11:05 AM
Validation file input and text input - by El Forum - 07-11-2012, 02:29 PM
Validation file input and text input - by El Forum - 07-11-2012, 02:53 PM
Validation file input and text input - by El Forum - 07-11-2012, 02:58 PM
Validation file input and text input - by El Forum - 07-12-2012, 01:50 AM
Validation file input and text input - by El Forum - 07-12-2012, 02:17 AM
Validation file input and text input - by El Forum - 07-13-2012, 10:48 AM



Theme © iAndrew 2016 - Forum software by © MyBB