2017-12-28 63 views
0

CodeIgniter에 사용자가 2 개의 파일을 업로드 할 수있는 양식이 있습니다. 백엔드에서는이 파일들을 다른 폴더에 저장하려고합니다. 컨트롤러에서 업로드 코드를 작성했습니다올바른 폴더에 파일이 저장되지 않음

public function upload() 
    { 
     /**Start uploading file**/ 
     $config['upload_path'] = './assets/file/.'; 
     $config['allowed_types'] = 'gif|jpg|png|doc|txt'; 
     $config['max_size'] = 1024 * 8; 
     $config['encrypt_name'] = TRUE; 

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

     if (!$this->upload->do_upload('file')) 
      { 
       $error = array('error' => $this->upload->display_errors()); 
       echo $error; 

      } 
     else 
      { 
       $data = $this->upload->data(); 
       echo $file = $data['file_name']; //name of file 

      } 

     /**End uploading file**/ 

     /**Start uploading img**/ 

     $config2['upload_path'] = './assets/img/.'; 
     $config2['allowed_types'] = 'gif|jpg|png|doc|txt'; 
     $config2['max_size'] = 1024 * 8; 
     $config2['encrypt_name'] = TRUE; 

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

     if (!$this->upload->do_upload('img')) 
      { 
       $error1 = array('error' => $this->upload->display_errors()); 
       echo $error1; 

      } 
     else 
      { 
       $data1 = $this->upload->data(); 
       echo $img = $data1['file_name']; //name of img 

      } 

     /**End uploading img**/ 
    } 

이미지가 업로드되고 있지만 같은 폴더에 업로드 중입니다.

$this->upload->initialize($config2); 
+0

이미지는 다음과 같습니다 부하 방법은 초기화하지 않기 때문에 사람이 내가 파일을 별도의 폴더 두 번째 부하 –

답변

2

에 저장 얻을 수있는 방법을 알려 주시기 바랍니다 수 있습니다, 당신은로드 라이브러리를 initialiaze 필요 flolder 파일에 업로드 하시겠습니까?
+0

감사합니다. – user3732711