0

I have the following:

<form id="set" method="post" action="<?php echo $base_url; ?>schedule" enctype="multipart/form-data">
<?php
     for($i=0;$i<10;$i++) {
?>
    <input type="file" name="file[]" class="selective_file">
    <input type="checkbox" name="name[]" value="<?php echo $name[$i]; ?>" style="display:none;"/>
<?php
     }
?>
   <input type="submit" value="Post />
</form>

The client has to submit 10 photos and once they click the button and the form is submitted, the schedule controller gets the files as follows

public function index() {   
    $files = $this->input->post('files');
    $name = $this->input->post('name');

    print_r($files);
    print_r($name);
}

I know that for uploading files in CI, the following has always worked for me

if(!$this->upload->do_upload('file')) {    
   $error = array('error' => $this->upload->display_errors());
   print_r($error);
} else {
    $pic = $this->upload->data();
    }

How do I identify the files with CI so that it can be uploaded successfully while looping thru the array of files with the correct corresponding name from the checkbox field?

Lance
  • 4,736
  • 16
  • 53
  • 90
  • You have a typo either in your PHP or HTML. Is it `file` or `files`? – MonkeyZeus Nov 21 '13 at 15:14
  • You might want to take a look at this SO question, the users question code is relevant to your scenario. http://stackoverflow.com/questions/1908247/codeigniter-multiple-file-upload – SamV Nov 21 '13 at 15:14

0 Answers0