[eluser]tusukgigi[/eluser]
how to insert data image from multiple upload form into database( and i have got error)
controller :
function create(){
if($this->input->post('submit')){
$config['upload_path'] = './uploads/files';
$config['allowed_types'] = 'gif|png|jpg';
$config['max_size'] = '70';
$config['max_width'] = '500';
$config['max_height'] = '450';
$newname = md5(uniqid(mt_rand()));
$config['file_name'] = $newname;
$this->load->library('upload');
$file = array();
foreach ($_FILES as $key => $row){
$this->upload->initialize($config);
if( !empty($row['name'])){
if(!$this->upload->do_upload($key)){
$data['error'] = $this->upload->display_errors();
$data['title'] = 'Add products';
$data['main'] = 'dashboard/p_jual_create';
$data['districts'] = $this->MPosts->getDistrictsDropDown();
$this->load->vars($data);
$this->load->view('/dashboard/template_admin');
}else{
$file = $this->upload->data();
$createthumbs = true;
$dokfilename = $newname.$file['file_ext'];
$data['upload_data'] = $file;
if($createthumbs){
$dokfile = $file['file_name'];
$config['image_library'] = 'gd2';
$config['source_image'] = 'uploads/files/'.$newname.$file['file_ext'];
$config['new_image'] = "./uploads/files/thumbs/";
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = FALSE;
$config['thumb_marker'] = "";
$config['width'] = 160;
$config['height'] = 140;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}
$this->MPosts->addPosts($dokfilename);
$this->session->set_flashdata('message', 'Product created');
redirect('management/index', 'location', 301);
}
}//end !empty($row['name']
} //end foreach
redirect('management/index', 'location', 301);
//} //end if empty
}else{
$data['title'] = 'Add products';
$data['main'] = 'dashboard/p_jual_create';
$data['districts'] = $this->MPosts->getDistrictsDropDown();
$this->load->vars($data);
$this->load->view('/dashboard/template_admin');
}
}
model :
function addPosts($dokfile){
$now = date("Y-m-d H:i
");
$randVal = rand(5, 100);
$randCode = $randVal."-".trim(strip_tags($this->input->post('house')));
$data = array(
'kode_rumah' => $randCode
'image1' => $dokfile,
'description' => trim(strip_tags($this->input->post('description')))
);
$this->db->insert('products',$data);
}
how to insert into database ($dokfile)
who can help me ???
please