codeigniter - Grocery Crud with Image Crud -
i've grocery crud on system , want use image crud grocerycrud multiple file upload. i've 2 tables attraction , attraction_images.
attractions ------> id , title, description attraction_images -----> attraction_id,attraction_image
public function attraction() { try{ $crud = new grocery_crud(); $crud->set_theme('datatables'); $crud->set_table('attractions'); $crud->set_subject('attraction'); $crud->required_fields('title'); $crud->field_type('description', 'text'); $crud->columns('title','description','image'); $crud->callback_before_insert(array($this,'remove_special_char')); $crud->set_field_upload('image','assets/uploads/files'); $crud->callback_column('image', array($this, 'callback_images')); $output = $crud->render(); $this->_example_output($output); }catch(exception $e){ show_error($e->getmessage().' --- '.$e->gettraceasstring()); } } } public function callback_images($value, $row) { $html = '<div>'; $attraction= $this->db->get_where('attraction_images',array('attraction_id' => $row->id))->result_array(); if($attraction) { foreach ($attraction $items) { $html.='<img src="'.base_url().'assets/uploads/files/'.$items['image'].'" style="width:200px;height:100px;"/>'; } } $html.='</div>'; return $html; }
now when user want add attraction want imagecrud uploadimage button option add multiple image single attraction , insert images path attraction_images table. i'm newbie imagecrud if buddy please me out.
thanks
Comments
Post a Comment