[eluser]heaversm[/eluser]
Hi - I followed the docs and created a standalone file uploader, but I'm having a little bit of trouble integrating into my pre-existing form. For simplicity's sake, I've left out the validation for now. This is my code:
form:
Code:
<?php echo form_open_multipart('control_form/add_group'); ?>
..
<label for="f_groupphoto">Group Photo</label>
<input type="file" name="f_groupphoto"/>
controller
Code:
function add_group(){
#Validate entry form information
$this->load->model('Model_form','', TRUE);
if ($this->form_validation->run() == FALSE)
{
//reload with validation errors
}
else
{
#Add Group to Database
$this->Model_form->add_group();
$this->load->view('view_inc_header');
$this->load->view('view_form_success');
$this->load->view('view_inc_footer');
}
}
Model:
Code:
function add_group()
{
$config['upload_path'] = './uploads/groups/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100'; //kb
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
....
$v_groupphoto = $this->upload->data();
//ALSO TRIED THIS: $v_groupphoto = $this->input->post('f_groupphoto');
$data = array(
'upload_data' => $this->upload->data(),
...
);
$this->db->insert('groups', $data);
}
Any idea where I'm going wrong? I get a few errors:
Code:
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: mysql/mysql_driver.php
Line Number: 535
and
Code:
A Database Error Occurred
Error Number: 1054
Unknown column 'Array' in 'field list'
INSERT INTO `groups` (`group_photo`, `id`, `tree_index`, `group_name`, `group_desc`, `group_parent`, `group_id`) VALUES (Array, NULL, '5', 'Pearl Jam', '', 'top', 'Pearl_Jam')
Filename: model_form.php
Line Number: 135