2012-10-12 43 views
0

此功能無法上傳超過2個圖像。如果試圖產生錯誤,CI多個文件上傳 - 無法上傳超過2個文件

消息:未定義指數:userfile的

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

控制器

function do_upload() { 

    $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'; 
            $config['max_size']  = 0; 

      $this->load->library('upload', $config); 
      $this->upload->do_upload(); 
      $data = $this->upload->data(); 
     } 
    } 

} 
+1

你確定它的文件的數量,這是問題?你有沒有嘗試上傳幾個小文件?它可能是你最大的上傳/張貼大小設置在Apache? – user1026361

+0

你能發表更多的視圖代碼嗎? – bottleboot

+0

感謝您指出,我不知道,我正在上傳10MB照片。已解決 – NestedWeb

回答

1

你一定要看看你的php.ini最大發布/上傳大小。看起來像值:

; Maximum allowed size for uploaded files. 
upload_max_filesize = ##M 

; Must be greater than or equal to upload_max_filesize 
post_max_size = ##M 

,並更改#至值,將滿足您