2016-11-26 36 views
0

下面是我的代碼。我正試圖將一張圖片保存在一個目錄中。數據正確到達數據庫,但目錄是空的。以下是我的控制代碼,請檢查並幫助我。無法上傳圖片到codeiginter框架中的目錄

public function addMakupTips() 
{ 

    $this->load->model('makuptipsmodel'); 


     //Uploading data 

     $config = array(
     'upload_path' => "./makupimages", 
     'allowed_types' => 'jpg|png|jpeg', 
     'overwrite'  => TRUE, 
     'encrypt_name' => TRUE,      
    ); 

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

    $files = $_FILES['uploads']; 

    foreach ($files['name'] as $key => $filename) { 
     $_FILES['uploads[]']['name']  = $files['name'][$key]; 
     $_FILES['uploads[]']['type']  = $files['type'][$key]; 
     $_FILES['uploads[]']['tmp_name'] = $files['tmp_name'][$key]; 
     $_FILES['uploads[]']['error'] = $files['error'][$key]; 
     $_FILES['uploads[]']['size']  = $files['size'][$key]; 

     $config['file_name'] = $filename; 

     $this->upload->initialize($config); 

       $uploads[] = $this->upload->data(); 
       $array = array(
        'name'  => $this->input->post('name'), 
        'category'  => $this->input->post('category'), 
        'title'  => $this->input->post('title'), 
        'poetry'  => $this->input->post('poetry'), 
        'keywords'  => $this->input->post('keywords'), 
        'image' => $_FILES['uploads[]']['name'] 

       ); 

       $this->makuptipsmodel->addData($array); 


    redirect(base_url() . 'admin/makuptips/index/' . $record_id); 

     //Uploading end 
     } 


} 

在上面的代碼中,我試圖用一張圖片在數據庫中保存一個完整的表單數據。這是我的表屏幕短

enter image description here

回答