[eluser]the_unforgiven[/eluser]
Hi guys,
I have a function do upload which works great, it uploads and resizes just fine, but now I need to have the ability to upload 3 or 4 images instead of just one image.
here's the do upload function:
Code:
function _do_upload_file()
{
//upload config
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png|pdf',
'upload_path' => $this->gallery_path,
'max_size' => 6000,
'overwrite' => false,
'remove_spaces' => true
);
$this->load->library('upload', $config);
$this->upload->initialize($config);
if (!$this->upload->do_upload())
{
$this->form_validation->set_message('_do_upload_file', $this->upload->display_errors());
return FALSE;
}
else
{
// Resize Config
$config['image_library'] = 'gd2';
$config['create_thumb'] = TRUE;
$config['source_image'] = $this->upload->upload_path.$this->upload->file_name;
$config['new_image'] = $this->gallery_path . '/thumbs';
$config['maintain_ratio'] = TRUE;
$config['thumb_marker'] = '_thumb';
$config['width'] = 150;
//echo $this->upload->upload_path.$this->upload->file_name . "<BR>";
$config['height'] = 100;
$this->load->library('image_lib', $config);
$this->image_lib->initialize($config);
$this->image_lib->resize();
if (!$this->image_lib->resize()){
$this->form_validation->set_message('_do_upload_file', $this->upload->display_errors());
}
}
}
Here's the model
Code:
function addproduct(){
$data = array(
'name' => $this->input->post('name'),
'short_description' => $this->input->post('short_description'),
'long_description' => $this->input->post('long_description'),
'status' => $this->input->post('status'),
'category' => $this->input->post('category'),
'featured' => $this->input->post('featured'),
'price' => $this->input->post('price'),
'code' => $this->input->post('code'),
'supplier' => $this->input->post('supplier'),
'supplier_code' => $this->input->post('supplier_code'),
'weight' => $this->input->post('weight')
);
$image_data = $this->upload->data();
$data['image'] = $image_data['file_name'];
$this->db->insert('products', $data);
redirect('admin/products');
}
Any help, advice code examples highly appreciated.
Thanks in advance...