2015-07-13 130 views
1

我上传我的图像使用codeigniter,上传的图像不显示在我的网站,然后我去了filezilla和搜索有关该文件,文件夹权限是755,但文件权限为600,如果我将文件权限更改为644,则图像显示正常,但对于所有上传图像,我都无法这样做。那么,有没有办法解决它?Codeigniter:上传的图片的权限是600的网络服务器,图像不显示在网站

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

回答

0

这try代码 变化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(''); 
     } 
+0

它是不会上传我的形象,而不是存储在服务器中。 – 151291

0
$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)