Codeigniter: Uploaded images permission is 600 in web server, images not displaying in website

∥☆過路亽.° 提交于 2019-12-24 13:25:40

问题


I uploaded my image using codeigniter, uploaded images not displaying in my website, then i went filezilla and searched about that file, the folder permission is 755 but file permission is 600, if i change the file permission to 644, then image displays fine, but i cann't do like this for all uploading images. so, is there any way to fix it?

            $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('');
            }

回答1:


This Try Code Change permision Folder Not File

$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('');
        }



回答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)


来源:https://stackoverflow.com/questions/31377917/codeigniter-uploaded-images-permission-is-600-in-web-server-images-not-display

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!