【问题标题】:change permission folder Codeigniter更改权限文件夹 Codeigniter
【发布时间】:2018-09-06 01:01:01
【问题描述】:

我想将文件夹 (big_pics) 的权限更改为模式 777。

function do_upload(){
    $config['upload_path']  = './big_pics/';
    $config['allowed_types']  = 'gif|jpg|png';
    $config['max_size']  = 100;
    $config['max_width']  = 1024;
    $config['max_height']  = 768;

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

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

        foreach($error as $key => $value){
            echo $value."<br>";
        }
        //$this->load->view('upload_form', $error);
    }else{
        echo "Well DOne";
        $data = array('upload_data' => $this->upload->data());
        $this->load->view('upload_success', $data);
    }
}

文件夹位于根文件夹。 我在这个项目中使用 codeigniter

【问题讨论】:

  • 代码与更改目录权限有什么关系?
  • 改进语法。

标签: php permissions image-uploading codeigniter-3


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2012-02-16
    • 2012-04-27
    • 2022-01-20
    • 1970-01-01
    • 1970-01-01
    • 2020-10-30
    • 1970-01-01
    • 2020-07-13
    • 1970-01-01
    相关资源
    最近更新 更多