dongsiju1941 2019-04-03 03:44
浏览 64

如何在forI中声明已经在CodeIgniter中声明的if和for语句

I'm trying to update my images table with new ones.

This is my controller:

        if(!empty($_FILES['gambar']['name'])){
            $filesNumber        =   sizeof($_FILES['gambar']['tmp_name']);
            $files          =   $_FILES['gambar'];
            $config['upload_path']          = './assets/img/pics/';
            $config['allowed_types']        = 'gif|jpg|png';
            $config['max_size']             = 2048;
            $config['encrypt_name']      = true;

            for ($i = 0; $i < $filesNumber ; $i++) {
                $_FILES['gambar']['name']       =   $files['name'][$i];
                $_FILES['gambar']['type']       =   $files['type'][$i];
                $_FILES['gambar']['tmp_name']   =   $files['tmp_name'][$i];
                $_FILES['gambar']['error']      =   $files['error'][$i];
                $_FILES['gambar']['size']       =   $files['size'][$i];

                $this->upload->initialize($config);
                if($this->upload->do_upload('gambar')){
                    $data = $this->upload->data();

                    $insert[$i]['kode_asset']   = $this->input->post('kode');
                    $insert[$i]['gambar']       = $data['file_name'];
                }
            }

        $this->db->insert_batch('gambar', $insert);
        redirect('admin/asset','refresh');
        }

This is input for multiple files:

<input type="file" name="gambar[]" id="gambar" class="form-control-file" multiple>

But it give Undefined variable: insert notice at the insert_batch syntax and You must use the "set" method to update an entry. db error every time. Can someone help me?

  • 写回答

1条回答 默认 最新

  • duandu1966 2019-04-03 03:49
    关注

    check the statement:

    // check filesNumber value, after see this , you may fix this quickly.
     $filesNumber        =   sizeof($_FILES['gambar']['tmp_name']);
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?