Codeigniter:Web服务器中的“上载图像"权限为600,网站上未显示图像 [英] Codeigniter: Uploaded images permission is 600 in web server, images not displaying in website

查看:93
本文介绍了Codeigniter:Web服务器中的“上载图像"权限为600,网站上未显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用codeigniter上传了图片,上传的图片未显示在我的网站上,然后我进入了filezilla并搜索了该文件,文件夹权限为755但文件权限为600,如果我将文件权限更改为644,则图片显示正常,但我不能对所有上传的图像都这样.因此,有什么办法可以解决?

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

推荐答案

    $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:Web服务器中的“上载图像"权限为600,网站上未显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆