[eluser]GreenDude[/eluser]
Hi there.
Just finished reading most of the the CI docs today (started this morning) and I wanted to build a site which features file uploads among other things. so I rounded this up:
Code:
class Face extends Controller {
function __construct()
{
parent::Controller();
$db_users = $this->load->database('users', TRUE);
$db_data = $this->load->database('data', TRUE);
$this->load->helper(array('form', 'url'));
}
function index()
{
$headdata['title'] = "MedieMareLaInfo";
$headdata['heading'] = "MedieMareLaInfo";
$headdata['base_url'] = $this->config->item('base_url');
$this->load->view('header', $headdata); echo $this->output->get_output();
$this->load->view('faceview'); echo $this->output->get_output();
$this->load->view('footer'); echo $this->output->get_output();
}
function dashboard()
{
$headdata['title'] = "MedieMareLaInfo Admin";
$headdata['heading'] = "MedieMareLaInfo Admin";
$headdata['base_url'] = $this->config->item('base_url');
$data['error'] = '';
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('validation');
$this->validation->set_error_delimiters('<div class="error">', '</div>');
$rules['username'] = "required";
$rules['password'] = "required";
$rules['passconf'] = "required";
$rules['email'] = "required";
$rules['userfile'] = "required";
$this->validation->set_rules($rules);
$fields['username'] = 'Username';
$fields['password'] = 'Password';
$fields['passconf'] = 'Password Confirmation';
$fields['email'] = 'Email Address';
$this->validation->set_fields($fields);
if ($this->validation->run() == FALSE)
{
$this->load->view('header', $headdata); echo $this->output->get_output();
$this->load->view('dashboard'); echo $this->output->get_output();
$this->load->view('upload_form', $data); echo $this->output->get_output();
$this->load->view('footer'); echo $this->output->get_output();
}
else
{
/*
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$data['error'] = $this->upload->display_errors();
}*/
$this->load->view('header', $headdata); echo $this->output->get_output();
$this->load->view('dashboard'); echo $this->output->get_output();
$this->load->view('upload_success'); echo $this->output->get_output();
$this->load->view('footer'); echo $this->output->get_output();
}
}
The problem is the file won't validate.. it keeps saying the field is empty. I've searched for an hour and still haven't found the reason.
Can you help me a bit please ?
CI is wonderful so far, by the way.
GreenDude