上传第th个图像需要对配置进行哪些更改?这是我的模型,图像名称存储在数据库中,但图像不会上传到文件夹中


what changes to need in config for upload th image?This is my model,image names are stored in database but images are not upload in folder

$name_array = array();              
$count = count($_FILES['prescription_image']['size']);
foreach($_FILES as $key=>$value)
for($s=0; $s<=$count-1; $s++) {
    $_FILES['userfile']['name'] = $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'] = './prescriptionimages/';
    $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('Image_name'=> $names);
$this->db->insert('precscription_image',$db_data);
print_r($names);
        $this->load->library('upload');
        $name_array = array();
        $files = $_FILES;
        $cpt = count($_FILES['userfile']['name']);
        $config['upload_path'] = './prescriptionimages/';
        for ($i = 0; $i < $cpt; $i++)
        {
            $_FILES['userfile']['name'] = $files['userfile']['name'][$i];
            $_FILES['userfile']['type'] = $files['userfile']['type'][$i];
            $_FILES['userfile']['tmp_name'] = $files['userfile']['tmp_name'][$i];
            $_FILES['userfile']['error'] = $files['userfile']['error'][$i];
            $_FILES['userfile']['size'] = $files['userfile']['size'][$i];
            $this->upload->initialize($config);
            if($this->upload->do_upload())
            {
                $data = $this->upload->data();
                $name_array[] = $data['file_name'];
            }
            else
            {
                $this->upload->display_errors(); exit; //just to stop here and verify the problem.
            }
        }
        print_r($name_array);

如果显示任何错误消息,请尝试此操作并发布。

在HTML表单中,用户如下还要检查表单的enctype属性。

File1 : <input type="file" name = "userfile[]">
File2 : <input type="file" name = "userfile[]">