Codeigniter图像操纵器无法保存图像

hquia 发布于 2019-03-09 codeigniter 最后更新 2019-03-09 14:36 0 浏览

那么我有以下问题: 我使用的是CodeIgniter 2.1.3,并希望上传图像并创建两个缩放图像。一个大小调整到50x50左右,一个大小调整到200x200左右。 上传工作正常。 但是当我想调整以下错误发生时: 无法保存图像。请确保图像和文件目录是可写的。 我已经将服务器上的权限设置为777,但仍然无法计算 这里是类的代码:

public function uploadimage()
    {
$head = array('title' => 'Upload Image');
        $error = array('error' => '');
                 $this->load->view('head',$head);
                 $this->load->view('imageUpload', $error);
                 $this->load->view('footer');
    }
public function changeimage()
    {
          $config = array();
          $config['upload_path'] = 'img/Upload';
          $config['allowed_types'] = 'gif|jpg|jpeg|png|bmp';
          $config['max_size']   = '100';
          $config['max_width']  = '200';
          $config['max_height']  = '200';
          $config['overwrite'] = TRUE;
          $config['file_name'] = md5($this->session->userdata('username')).".png";
$head = array('title' => 'Upload Image');
          $this->upload->initialize($config);
if ( ! $this->upload->do_upload())
          {
                 $error = array('error' => $this->upload->display_errors());
                 $this->load->view('head',$head);
                 $this->load->view('imageUpload', $error);
                 $this->load->view('footer');
          }
          else
          {
             $uploaddata = $this->upload->data();
//Create Thumb
              $config2 = array();
              $config2['image_library'] = 'gd';
              $config2['source_image']  = $uploaddata['full_path'];
              $config2['maintain_ratio'] = TRUE;
              $config2['width']  = 50;
              $config2['height'] = 50;
              $config2['new_image'] = '/~3612546/DateSite/img/ProfileThumbs/'.$uploaddata['file_name'];
              $this->image_lib->initialize($config2);
              if ( ! $this->image_lib->resize())
              {
                echo $this->image_lib->display_errors();
              }
//Create resized original image so images < 200x200 get resized to get as close to 200x200
              $config3 = array();
              $config3['image_library'] = 'gd';
              $config3['source_image']  =$uploaddata['full_path'];
              $config3['maintain_ratio'] = TRUE;
              $config3['width']  = 200;
              $config3['height'] = 200;
              $config3['new_image'] = '/~3612546/DateSite/img/ProfileImages/'.$uploaddata['file_name'];
              $this->image_lib->initialize($config3);
              if ( ! $this->image_lib->resize())
              {
                  echo $uploaddata['full_path'];
                  echo $this->image_lib->display_errors();
              }
}
    }
已邀请:

gautem

赞同来自:

我真的不认为代字号对上传网址有好处:

/~3612546/DateSite/img/ProfileImages/
然后,你的所有网址都是大写/小写,将它们全部放到小写,如下所示:
/~3612546/dateSite/img/profileimages/
在最后发布你收到什么错误,你chmod 777你的上传文件夹,你是否只将d77添加到dir或dir +他的所有内容? (这是重要的目录+他所有的内容777)