2017-09-01 45 views
0

這裏控制器頁面,在這裏形象的名字被插入到數據庫中,但圖像沒有進入相應的目錄這裏圖像更新數據庫,而不是在目錄

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

刪除'$ this-> upload-> initialize($ config);'line。如果您在加載類上傳遞第二個參數,則不需要使用config數組初始化類。 – Tpojka

+0

@Tpojka因此在上傳目錄中沒有filgets –

+0

您沒有使用上傳功能,但期望文件被上傳? – Tpojka

回答

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); 
    } 
+0

我不使用do_upload函數 –

+0

@jibinkj然後你需要使用 –

+0

@ Mayank Vadiya因此沒有輸出 –

相關問題