Codeigniter未初始化的字符串偏移量:0错误

时间:2014-05-14 11:43:17

标签: php codeigniter

您好我的项目中有控制器,每当我尝试运行此代码时

$name_array = array();
        $uniqueid=uniqid();
        $count = count($_FILES['userfile']['size']);

        foreach($_FILES as $key=>$value)

        for($s=0; $s<=$count-1; $s++) {
          $_FILES['userfile']['name'] = $uniqueid.$value['name'][$s];
          $_FILES['userfile']['type']    = $value['type'][$s];
          $_FILES['userfile']['tmp_name'] = $value['tmp_name'][$s];
          $_FILES['userfile']['error']       = $value['error'][$s];
          $_FILES['userfile']['size']    = $value['size'][$s];   
          $config['upload_path'] = './uploads/';
          $config['allowed_types'] = 'gif|jpg|png';
          $config['max_size']    = '100';
          $config['max_width']  = '1024';
          $config['max_height']  = '768';
          $this->load->library('upload', $config);
          $this->upload->do_upload();
          $data = $this->upload->data();
          $name_array[] = $data['file_name'];
        }
            $names= implode(',', $name_array);
/*            $this->load->database();
            $db_data = array('id'=> NULL,
                             'name'=> $names);
        $this->db->insert('testtable',$db_data);
*/            print_r($names);

我收到此错误。

A PHP Error was encountered

Severity: Notice

Message: Uninitialized string offset: 0

Filename: controllers/client.php

Line Number: 519

有人知道如何解决此错误未初始化的字符串偏移量:0?

0 个答案:

没有答案