这里图像在数据库上更新但在目录中没有

时间:2017-09-01 06:30:26

标签: codeigniter

这里是控制器页面,这里图像名称被插入到数据库中,但图像没有进入相应的目录

    if(isset($_POST['submit']))
      {  
     $config['upload_path']   = './upload/';
     $config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|mp4';         

     $this->load->library('upload', $config);
     $this->upload->initialize($config);


        $data = array
        (
         'student_name' => $this->input->post('dname'),
         'student_email' => $this->input->post('demail'),
         'student_mobile' => $this->input->post('dmobile'),
         'student_address' => $this->input->post('daddress'),

            'picture' => $_FILES['picture']['name'] 
        );
     }

      $insertuserdata=$this->Inserts_model->form_insert($data);

此处查看页面

<form action="<?php echo site_url('Insert_ctrl/index/'); ?>"   
  method="post" enctype="multipart/form-data">
  <label>NAME</label>
  <input type="text" name="dname" required onkeyup="textt(this)"  
  id="name"><br>
  <label>email</label>
  <label>Picture</label>
  <input class="form-control" type="file" name="picture" /><br>
  <input type="submit" name="submit" value ="submit">
</form>

1 个答案:

答案 0 :(得分:1)

你应该尝试这样

$config['upload_path']   = './upload/';
$config['allowed_types'] = 'gif|jpg|png|jpeg|pdf|mp4';         

 $this->load->library('upload', $config);
 $this->upload->initialize($config);

if(!$this->upload->do_upload('picture'))
 {
    $error = array('error' => $this->upload->display_errors());
     print_r($error);
 }
 else{
    $data = array('upload_data' => $this->upload->data());
    print_r($data);
  }