1

I have to upload multiple images in CodeIgniter. The result of var_dump($_FILES) is :

array
      'organizer_logo' => 
        array
          'name' => 
            array
              0 => string 'Best Wallpapers 2009 (Fun12.com) 01.jpg' (length=39)
              1 => string 'Best Wallpapers 2009 (Fun12.com) 05.jpg' (length=39)
          'type' => 
            array
              0 => string 'image/jpeg' (length=10)
              1 => string 'image/jpeg' (length=10)
          'tmp_name' => 
            array
              0 => string 'D:\wamp\tmp\php1238.tmp' (length=23)
              1 => string 'D:\wamp\tmp\php1239.tmp' (length=23)
          'error' => 
            array
              0 => int 0
              1 => int 0
          'size' => 
            array
              0 => int 142036
              1 => int 269895
kittycat
  • 14,983
  • 9
  • 55
  • 80
yajay
  • 1,050
  • 10
  • 24

1 Answers1

-1

Have a separate config array for each image and then upload. like below

//I have given an exmaple for one image repeat this for others,
$config_image[0]['allowed_types'] =  'gif|jpg|png';
$config_image[0]['overwrite'] =TRUE;
$config_image[0]['subcategory_image']['upload_path'] = './public/subcategory/';
$config_image[0]['subcategory_image']['file_name'] = $this->input->post('subcategory_name');


//Load and initialize the library as below and then upload
$this->load->library('upload', $config_image[0]);
$this->upload->initialize($config_image[0]); 
Shaolin
  • 2,541
  • 4
  • 30
  • 41
  • @cryptic - You have misunderstood. This answer was given on how to add images to config array, he can use small function to add any number of images to config array and then loop through and upload. Why don't you give a better answer rather than just commenting. – Shaolin Apr 08 '13 at 08:15