笨:上传的图片的权限是在网络服务器600,图像不是在网站上显示(Codeigniter: Uploa

2019-10-23 19:42发布

我上传我的形象使用笨,上传的图片在我的网站不显示,然后我去FileZilla中和搜索有关的文件,文件夹权限是755,但文件权限是600,如果我更改文件权限为644,则图像显示细腻,只是还是熬不过做这样为所有上传图片。 那么,有没有什么办法解决?

            $config['upload_path'] = './assets/images/';
            $config['allowed_types'] = 'gif|jpg|png';
            $config['max_size'] = '100';
            $config['max_width']  = '600';
            $config['max_height']  = '600';
            $config['file_name']  = $id;

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

            if(!$this->upload->do_upload())
            {
                $error = array('error' => $this->upload->display_errors());                 
                redirect('', $error);
            }
            else
            {
                chmod($config['upload_path'], 0755);
                redirect('');
            }

Answer 1:

这种尝试代码更改permision文件夹而不是文件

$config['upload_path'] = chmod('./assets/images/', 0755);
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size'] = '100';
        $config['max_width']  = '600';
        $config['max_height']  = '600';
        $config['file_name']  = $id;

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

        if(!$this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());                 
            redirect('', $error);
        }
        else
        {
            $config['upload_path'];
            redirect('');
        }


Answer 2:

    $config['upload_path'] = './assets/images/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size'] = '100';
    $config['max_width']  = '600';
    $config['max_height']  = '600';
    $config['file_name']  = $id;
    $uploadata = array('upload_data' => $this->upload->data());
    $perfile = $uploadata ['upload_data']['full_path'];
    chmod($perfile ,0777)


文章来源: Codeigniter: Uploaded images permission is 600 in web server, images not displaying in website