2012-02-16 6 views
0

CodeIgniterで複数のファイルをアップロードしようとしていますが、エラーが発生しています: You did not select a file to upload Codeigniterで複数のファイルをアップロードするとエラーが発生する

私のhtmlコード:

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

私のPHPコード:nameパラメータがなければなりません

for($i = 0; $i < count($_FILES['ModelImage']["name"]); $i++) 
{ 
    if (!empty($_FILES['ModelImage']['name'][$i])) 
    { 
    $config['upload_path'] = './uploads/starmodel/'; 
    $config['allowed_types'] = 'gif|jpg|png'; 
    $config['file_name']= "star_".$lastid."_".$i.strrchr(basename($_FILES["ModelImage"]["name"][$i]),"."); 
    $this->upload->initialize($config); 

    if ($this->upload->do_upload('ModelImage')) 
    { 
     $data = $this->upload->data(); 
     $udata = array('ModelImage' => $config['file_name']); 
     $this->db->where('ModelID', $lastid); 
     $this->db->update('starmodel', $udata); 
    } 
    else 
    { 
     echo $this->upload->display_errors(); 
    } 
    } 
} 

答えて

0

to the CI File Uploading Documentationよる

userfile:

By default the upload routine expects the file to come from a form field called userfile, and the form must be a "multipart" type:

<form method="post" action="some_action" enctype="multipart/form-data" /> 
    <input type="file" name="userfile" size="20" /> 
    <input type="submit" value="upload" /> 
</form> 

これは、CIのライブラリが現在、HTML5の複数のファイルをアップロードしているとは思いません。ファイルがアップロードされています。カスタムライブラリの場合はpeak around CI's forumsにする必要があります。

+0

リプレイに感謝します。 @jordan Arsenault –

関連する問題