为什么我的codeigniter会更改权限

时间:2015-09-16 06:51:22

标签: php codeigniter model-view-controller file-upload

通过在codeigniter中使用文件上传类,它在文件夹/上传时成功上传文件,(当无法查看图像时)发现所有文件都被上传为权限600,即使是关注类似问题

stackoverflow - similar question

代码:::

 <?php

public function update($id)
{
    $this->check_login();
    $this->load->model('admin_user');
    // File Upload  ///
    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['overwrite'] = TRUE;
    $config['max_size'] = '100';
    $config['max_width'] = '1024';
    $config['max_height'] = '768';
    $this->load->library('upload', $config);
    //$this->upload->initialize($config);
    if(!$this->upload->do_upload('file')) {
    echo $this->upload->display_errors();
    } else {
    $file_name = $this->upload->data();
    }
// File Upload //

1 个答案:

答案 0 :(得分:2)

您可以在上传前使用此权限更改文件的权限

$zdata = array('upload_data' => $this->upload->data()); // get data
$zfile = $zdata['upload_data']['full_path']; // get file path
chmod($zfile, 0777); // CHMOD file
 if(!$this->upload->do_upload('file')) { 
    echo $this->upload->display_errors();
    } else { 
    $file_name = $this->upload->data();
    }