Multiple images and data upload |
i'm beginner in codeigniter i want to upload multiple images and data upload and save images name in database. i don't understand how to store multiple files name in database. And upload images in my root folder.
Here is my code View: <form method="post" enctype="multipart/form-data" action="<?=base_url();?>vendors/home/do_upload"> <input type="text" name="product_name" class="form-control" required> <input type="text" name="product_price" class="form-control" required> <input type="text" name="old_price" class="form-control" required> <input type="file" name="image1" required> <input type="file" name="image2" required> <input type="file" name="image3" required> <input type="file" name="image4" required> </form> Controller: public function do_upload() { if ($_POST) { $config['upload_path'] = './uploads/'; $config['max_size'] = 90000; $config['max_width'] = 50000; $config['max_height'] = 50000; $config['allowed_types'] = 'jpg|png|gif|jpeg'; $this->load->library('upload',$config); if (!$this->upload->do_upload()) { $error = array('error' => $this->upload->display_errors()); $this->load->view('vendors/add_product',$error); } else{ $query = $this->upload->data(); $data = array( 'pro_name' => $_POST['product_name'], 'prod_price' => $_POST['product_price'], 'old_price' => $_POST['old_price'], 'prod_image1' => [' '], 'prod_image2' => [' '], 'prod_image3' => [' '], 'prod_image4' => [' '], ); $this->venmod->add_product($data); redirect(base_url().'vendors/'); } $this->load->view('footer'); } } Model: public function add_product($data) { $this->db->insert('vendor_products',$data); } |
Messages In This Thread |
Multiple images and data upload - by azharsaleem6 - 02-29-2016, 07:38 AM
RE: Multiple images and data upload - by Wouter60 - 02-29-2016, 01:03 PM
RE: Multiple images and data upload - by azharsaleem6 - 02-29-2016, 09:02 PM
RE: Multiple images and data upload - by Mangetsu - 03-01-2016, 03:37 AM
RE: Multiple images and data upload - by Wouter60 - 03-01-2016, 01:20 PM
|