@shyann
To upload multiple images using CodeIgniter, you can follow these steps:
1 2 3 4 |
<form action="<?php echo base_url('upload/upload_images'); ?>" method="post" enctype="multipart/form-data"> <input type="file" name="userfile[]" multiple> <input type="submit" value="Upload Images"> </form> |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<?php class Upload extends CI_Controller { public function __construct() { parent::__construct(); $this->load->helper(array('form', 'url')); } public function upload_images() { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = 10000; // maximum size in KB $this->load->library('upload', $config); if (!$this->upload->do_upload('userfile')) { $error = array('error' => $this->upload->display_errors()); print_r($error); } else { $data = array('upload_data' => $this->upload->data()); print_r($data); } } } ?> |
This example demonstrates how to upload multiple images using CodeIgniter's file upload library. You can modify the code to suit your specific requirements, such as adding validation, resizing images, or saving image paths to a database.