繁体   English   中英

具有CodeIgniter上传类的文件权限

[英]File permission with upload class of CodeIgniter

嗨,我需要将权限777放到我上传的文件中,但我没有在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);
    }

您可以使用chmod更改权限。 这样的事可能有用。 在do_upload之后,您可以尝试添加以下行

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

你可以使用chmodumask

$old = umask(0);
$logofilepath = $config['upload_path'].$filename;
if(is_file($logofilepath))
{
chmod($logofilepath, 0777);
}
umask($old);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM