gpt4 book ai didi

php - 具有 CodeIgniter 上传类的文件权限

转载 作者:可可西里 更新时间:2023-11-01 13:24:54 32 4
gpt4 key购买 nike

您好,我需要对上传的文件设置权限 777,但我在 codeigniter 中找不到任何关于上传文件的文档...是否可以对 codeigniter 的上传类设置权限 777??

$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
}

关于php - 具有 CodeIgniter 上传类的文件权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8822255/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com