2012-01-11 3 views
5

안녕하세요 저는 업로드 된 파일에 권한 777을 넣어야하지만 codeigniter에 업로드 된 파일에 대한 문서는 찾을 수 없습니다 ... codeigniter의 업로드 클래스에 권한 777을 넣을 수 있습니까? ?CodeIgniter 업로드 클래스의 파일 사용 권한

$ group_id = $ this-> input-> post ('group_id', TRUE);

// unlink('static/images/uploads/44'); 
    // rmdir('static/images/uploads/45'); 

    $dir = is_dir('../www/static/images/uploads/'.$group_id); 
    if($dir){ 
      $config['upload_path'] = '../www/static/images/uploads/'.$group_id; 
      echo "test"; 
    } 

    else{ 
     mkdir('../www/static/images/uploads/'.$group_id, 0777); 
     $config['upload_path'] = '../www/static/images/uploads/'.$group_id; 
    } 


    $config['allowed_types']  = 'docx|pdf|doc|gif|jpg|png|tiff'; 
    $config['max_size'] = '10000000'; 
    $config['max_width'] = '999999'; 
    $config['max_height'] = '99999'; 
    $this->load->model('Teacher_model'); 



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

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

     print_r($error); 

     //$this->load->view('school/teacher/upload_form', $error); 
    } 
    else 
    { 
     $data = array('upload_data' => $this->upload->data()); 



      $name = $this->input->post('name', TRUE); 
      $path = $data['upload_data']['file_name']; 
      $group_id = $this->input->post('group_id', TRUE); 

      $this->Teacher_model->add_ressources($group_id,$name,$path); 


     redirect('school/teachers/#tabs_group_ressource'.$group_id, 'location', 301); 
    } 

답변

3

chmod를 사용하여 권한을 변경할 수 있습니다. 이런 식으로하면 효과가있을 수 있습니다. do_upload 후에 다음 줄을 추가해보십시오.

if(is_file($config['upload_path'])) 
{ 
    chmod($config['upload_path'], 777); ## this should change the permissions 
}