EllisLab text mark
Advanced Search
     
Multiple file upload, can’t upload more than 2
Posted: 12 October 2012 10:23 AM   [ Ignore ]
Joined: 2012-10-12
3 posts

View

<input name="userfile[]" id="userfile" type="file" multiple="" /> 

Controller

function doupload() {
 
  $path 
= array();
  
$count count($_FILES['userfile']['size']);
  
  foreach(
$_FILES as $key=>$value){
   
for($n=0$n<=$count-1$n++) {
    $_FILES[
'userfile']['name']=$value['name'][$n];
    
$_FILES['userfile']['type']    $value['type'][$n];
    
$_FILES['userfile']['tmp_name'$value['tmp_name'][$n];
    
$_FILES['userfile']['error']       $value['error'][$n];
    
$_FILES['userfile']['size']    $value['size'][$n];   

     
$config['upload_path''./images/';
     
$config['allowed_types''gif|jpg|png|jpeg';
     
    
$this->load->library('upload'$config);
    
$this->upload->do_upload();
    
$data $this->upload->data();
   
}
  } 
  
 } 

If more than 2 images are selected,produces error: Undefined index:userfile.

 
Posted: 12 October 2012 10:56 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2012-10-12
3 posts

Solved: It was because i was uploading 10mb photos, once i selected small sized ones, it worked perfectly.