2015-09-17 64 views
0

我有下面的代碼運行在Linux上的mint 64位操作系統上的Apache。發現文件無法保存在服務器上。你知道如何解決?添加更多配置或特權?codeigniter框架上傳保存在Linux薄荷

$config['file_name'] = basename($imgPath); 
      $config['upload_path'] = $upload_dir; 
      $config['allowed_types'] = 'gif|jpg|png|bmp'; 

      $this->upload->initialize($config); 
      if (! $this->upload->do_upload("image".$i)) 

$this->image_lib->clear(); 
       $config2['image_library'] = 'gd2'; 
       $config2['source_image'] = $this->upload->upload_path.$this->upload->file_name; 
       $config2['new_image'] = $upload_dir_resize.'/'.$thumb_fileName; 
       $config2['maintain_ratio'] = TRUE; 
       $config2['width'] = 320; 
       $config2['height'] = 320; 
       $this->image_lib->initialize($config2); 
       if (!$this->image_lib->resize()){ 
+0

什麼是你在這個錯誤,發佈錯誤? –

回答

0

你需要確保你有你保存在文件夾上0777權利。

if(!file_exists($folderPath)) 
    mkdir($folderPath, 0777, TRUE); 

$config['upload_path'] = $folderPath; 
$config['file_name']  = randomStringName(); 
$config['allowed_types'] = 'jpg|png|bmp'; 
$config['max_size']  = '1024'; // 1MB~ 
$config['overwrite']  = FALSE; 

if($this->upload->do_upload('image') == FALSE) 
    die('Ups...something went wrong'); 

$filePath = base_url() . $folderPath . $this->upload->data()['file_name'];