フォームに 3 つの入力ファイル フィールドがあり、フォームを送信するたびに最初のファイルのみが送信され、他のファイルは画像フォルダーに存在しません。
これが私のコントローラーでのやり方です:
public function book()
{
$id = $this->manage_model->book();
$images = array("1","2","3");
$this->load->library('upload');
foreach($images as $i){
if(!empty($_FILES['files'.$i]['name']))
{
$config['file_name'] = $id . '_' . $i;
$config['upload_path'] = './photos/';
$config['allowed_types'] = 'jpg|png';
$this->upload->initialize($config);
$name = "files" . $i;
if ( ! $this->upload->do_upload($name))
{
//set flashdata
redirect('manage/add_page');
}
else
{
redirect('manage/add_page');
}
}
}
}
これらはファイル入力フィールドの名前です。
<input type="file" name="files1" />
<input type="file" name="files2" />
<input type="file" name="files3" />
私は自分のフォームで multipart と post メソッドを使用しているので、それも問題ではありません。誰かが何か間違っていると思いますか?私にお知らせください